From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 1BEC61F4B4 for ; Wed, 31 Mar 2021 22:13:16 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C8447120FE4; Thu, 1 Apr 2021 07:12:14 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 329F6120FE3 for ; Thu, 1 Apr 2021 07:12:12 +0900 (JST) Received: by filterdrecv-p3iad2-7d7c446bd4-6v772 with SMTP id filterdrecv-p3iad2-7d7c446bd4-6v772-20-6064F3F5-D 2021-03-31 22:13:09.093085459 +0000 UTC m=+704415.502236499 Received: from herokuapp.com (unknown) by ismtpd0182p1mdw1.sendgrid.net (SG) with ESMTP id IL3ayzwnTGCPMzWurFf9fg for ; Wed, 31 Mar 2021 22:13:09.003 +0000 (UTC) Date: Wed, 31 Mar 2021 22:13:09 +0000 (UTC) From: jean.boussier@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 79177 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17765 X-Redmine-Issue-Author: lenwood X-Redmine-Sender: byroot X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?AchqQMoUBMcQgz7gop0XiYUiatGIY7E61JGsTL4FvjcDLrPzOnd1C98PLd6IA6?= =?us-ascii?Q?9P5x46md2NovFHZCHRakORweLzctG1nDkGipZwE?= =?us-ascii?Q?D+egRKBfgA++V3ZOkFT41c2nUZEEN7i42gL1aZI?= =?us-ascii?Q?5mSjGeKNxQZtUsbu0+OmJf+HGzwYukLW38+xDd9?= =?us-ascii?Q?N=2FIUThaSyfhqrb2tPg9Rw3gnw9SnXGY8dwc+Dgq?= =?us-ascii?Q?B=2FOThPmIpD1NkrFkQ=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103134 Subject: [ruby-core:103134] [Ruby master Bug#17765] Segmentation fault when calling String#gsub X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17765 has been updated by byroot (Jean Boussier). > But without success so far. I wouldn't be surprised if the bug wasn't in `gsub` itself, but in some C extension that would generate a faulty string on which `gsub` would trip. I see you have `thrift` loaded for instance. IIRC that's a binary format parser like protobuf etc, it might be creating strings improperly. This could prove very hard to track. ---------------------------------------- Bug #17765: Segmentation fault when calling String#gsub https://bugs.ruby-lang.org/issues/17765#change-91207 * Author: lenwood (Paul Martensen) * Status: Open * Priority: Normal * ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux-musl] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- We recently had a ruby segfault occuring while invoking `String#gsub`. The line in the code looks like this: ``` ruby def sanitize_for_prometheus(string_or_symbol) reg = /[^a-zA-Z_0-9]/ string_or_symbol.to_s.downcase.gsub(reg, '_') end ``` And we've tried to replicate the segfault (on a different machine) with this script: ```rb def sanitize_for_prometheus(string_or_symbol) reg = /[^a-zA-Z_0-9]/ string_or_symbol.to_s.downcase.gsub(reg, '_') end def rand_string_or_symbol @o ||= [('a'..'z').to_a, ('A'..'Z').to_a, (0..9).to_a, '-', '.'].flatten str = @o.sample(50).join rand > 0.5 ? str.to_sym : str end loop { sanitize_for_prometheus rand_string_or_symbol } ``` But without success so far. I have attached a shortened version of the log file for reference. ---Files-------------------------------- segfault.log (60.8 KB) segfault_gsub.rb (343 Bytes) -- https://bugs.ruby-lang.org/