[ruby-core:115466] [Ruby master Bug#20020] Segfault running regexp match?
Issue #20020 has been reported by andrea.salicetti@gmail.com (Andrea Salicetti). ---------------------------------------- Bug #20020: Segfault running regexp match? https://bugs.ruby-lang.org/issues/20020 * Author: andrea.salicetti@gmail.com (Andrea Salicetti) * Status: Open * Priority: Normal * ruby -v: 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- **Ruby version** : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] From `irb`, trying to call `match?` on this regular expression causes a segmentation falut: ```ruby irb(main):001:0> /^((a|c)|\s?){1,3}$/.match?('abc') => false irb(main):002:0> /^((a|c)|\s?){1,3}$/.match?('abc') (irb):2: [BUG] Segmentation fault at 0x000000061ba998e8 ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0037 p:---- s:0207 e:000206 CFUNC :match? c:0036 p:0006 s:0202 e:000201 EVAL (irb):2 [FINISH] c:0035 p:---- s:0199 e:000198 CFUNC :eval c:0034 p:0020 s:0191 e:000190 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/workspace.rb:119 c:0033 p:0153 s:0183 e:000181 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/context.rb:502 c:0032 p:0119 s:0170 e:000169 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:588 c:0031 p:0024 s:0164 e:000163 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:777 c:0030 p:0007 s:0158 e:000157 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:567 c:0029 p:0126 s:0153 e:000152 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:267 [FINISH] c:0028 p:---- s:0149 e:000148 CFUNC :loop c:0027 p:0005 s:0145 e:000144 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:249 [FINISH] c:0026 p:---- s:0142 e:000141 CFUNC :catch c:0025 p:0010 s:0137 e:000136 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:248 c:0024 p:0050 s:0132 E:000dd8 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:566 c:0023 p:0003 s:0127 e:000126 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:500 [FINISH] c:0022 p:---- s:0124 e:000123 CFUNC :catch c:0021 p:0050 s:0119 E:000d50 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:499 c:0020 p:0069 s:0113 e:000112 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:421 c:0019 p:0012 s:0107 e:000106 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11 [FINISH] c:0018 p:---- s:0104 e:000103 CFUNC :load c:0017 p:0078 s:0099 e:000098 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/irb:25 [FINISH] c:0016 p:---- s:0094 e:000093 CFUNC :load c:0015 p:0064 s:0089 e:000088 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58 c:0014 p:0050 s:0083 e:000082 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23 c:0013 p:0034 s:0078 e:000077 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492 c:0012 p:0054 s:0073 e:000072 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:28 c:0011 p:0040 s:0065 e:000064 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127 c:0010 p:0213 s:0058 e:000057 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:527 c:0009 p:0008 s:0045 e:000044 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34 c:0008 p:0044 s:0040 e:000039 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:584 c:0007 p:0022 s:0033 e:000032 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28 c:0006 p:0042 s:0028 e:000027 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:37 c:0005 p:0007 s:0022 e:000021 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117 c:0004 p:0108 s:0017 E:0019b8 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:29 [FINISH] c:0003 p:---- s:0013 e:000012 CFUNC :load c:0002 p:0081 s:0008 E:000220 EVAL /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/bundle:25 [FINISH] c:0001 p:0000 s:0003 E:001980 DUMMY [FINISH] ``` Sometimes this happens the very first time I try to execute the command, some other times I have to try a couple of times to see that Segmentation Fault (but usually within the first 5 attempts). ---Files-------------------------------- ruby-2023-11-23-175410.ips (20.2 KB) -- https://bugs.ruby-lang.org/
Issue #20020 has been updated by rubyFeedback (robert heiler). Interesting indeed. I tested this briefly in a standalone .rb file; first I got "Aborted (core dumped)", then lateron I got: false (Content of that .rb file was simply:) puts /^((a|c)|\s?){1,3}$/.match?('abc') It's interesting that this shows a different behaviour. Perhaps if someone has time, it may be helpful for others to learn something and explain why this leads to a segfault sometimes and to no segfault at other times. ---------------------------------------- Bug #20020: Segfault running regexp match? https://bugs.ruby-lang.org/issues/20020#change-105394 * Author: andrea.salicetti@gmail.com (Andrea Salicetti) * Status: Open * Priority: Normal * ruby -v: 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- **Ruby version** : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] From `irb`, trying to call `match?` on this regular expression causes a segmentation falut: ```ruby irb(main):001:0> /^((a|c)|\s?){1,3}$/.match?('abc') => false irb(main):002:0> /^((a|c)|\s?){1,3}$/.match?('abc') (irb):2: [BUG] Segmentation fault at 0x000000061ba998e8 ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0037 p:---- s:0207 e:000206 CFUNC :match? c:0036 p:0006 s:0202 e:000201 EVAL (irb):2 [FINISH] c:0035 p:---- s:0199 e:000198 CFUNC :eval c:0034 p:0020 s:0191 e:000190 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/workspace.rb:119 c:0033 p:0153 s:0183 e:000181 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/context.rb:502 c:0032 p:0119 s:0170 e:000169 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:588 c:0031 p:0024 s:0164 e:000163 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:777 c:0030 p:0007 s:0158 e:000157 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:567 c:0029 p:0126 s:0153 e:000152 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:267 [FINISH] c:0028 p:---- s:0149 e:000148 CFUNC :loop c:0027 p:0005 s:0145 e:000144 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:249 [FINISH] c:0026 p:---- s:0142 e:000141 CFUNC :catch c:0025 p:0010 s:0137 e:000136 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:248 c:0024 p:0050 s:0132 E:000dd8 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:566 c:0023 p:0003 s:0127 e:000126 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:500 [FINISH] c:0022 p:---- s:0124 e:000123 CFUNC :catch c:0021 p:0050 s:0119 E:000d50 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:499 c:0020 p:0069 s:0113 e:000112 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:421 c:0019 p:0012 s:0107 e:000106 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11 [FINISH] c:0018 p:---- s:0104 e:000103 CFUNC :load c:0017 p:0078 s:0099 e:000098 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/irb:25 [FINISH] c:0016 p:---- s:0094 e:000093 CFUNC :load c:0015 p:0064 s:0089 e:000088 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58 c:0014 p:0050 s:0083 e:000082 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23 c:0013 p:0034 s:0078 e:000077 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492 c:0012 p:0054 s:0073 e:000072 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:28 c:0011 p:0040 s:0065 e:000064 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127 c:0010 p:0213 s:0058 e:000057 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:527 c:0009 p:0008 s:0045 e:000044 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34 c:0008 p:0044 s:0040 e:000039 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:584 c:0007 p:0022 s:0033 e:000032 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28 c:0006 p:0042 s:0028 e:000027 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:37 c:0005 p:0007 s:0022 e:000021 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117 c:0004 p:0108 s:0017 E:0019b8 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:29 [FINISH] c:0003 p:---- s:0013 e:000012 CFUNC :load c:0002 p:0081 s:0008 E:000220 EVAL /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/bundle:25 [FINISH] c:0001 p:0000 s:0003 E:001980 DUMMY [FINISH] ``` Sometimes this happens the very first time I try to execute the command, some other times I have to try a couple of times to see that Segmentation Fault (but usually within the first 5 attempts). ---Files-------------------------------- ruby-2023-11-23-175410.ips (20.2 KB) -- https://bugs.ruby-lang.org/
Issue #20020 has been updated by nobu (Nobuyoshi Nakada). It seems reproducing only on IRB, but not without IRB. ```shell-session $ ruby3.2 -v -e 'p 1000.times.any? {/^((a|c)|\s?){1,3}$/.match?("abc")}' ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22] false ``` And does not with 3.3. ---------------------------------------- Bug #20020: Segfault running regexp match? https://bugs.ruby-lang.org/issues/20020#change-105397 * Author: andrea.salicetti@gmail.com (Andrea Salicetti) * Status: Open * Priority: Normal * ruby -v: 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- **Ruby version** : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] From `irb`, trying to call `match?` on this regular expression causes a segmentation falut: ```ruby irb(main):001:0> /^((a|c)|\s?){1,3}$/.match?('abc') => false irb(main):002:0> /^((a|c)|\s?){1,3}$/.match?('abc') (irb):2: [BUG] Segmentation fault at 0x000000061ba998e8 ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0037 p:---- s:0207 e:000206 CFUNC :match? c:0036 p:0006 s:0202 e:000201 EVAL (irb):2 [FINISH] c:0035 p:---- s:0199 e:000198 CFUNC :eval c:0034 p:0020 s:0191 e:000190 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/workspace.rb:119 c:0033 p:0153 s:0183 e:000181 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/context.rb:502 c:0032 p:0119 s:0170 e:000169 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:588 c:0031 p:0024 s:0164 e:000163 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:777 c:0030 p:0007 s:0158 e:000157 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:567 c:0029 p:0126 s:0153 e:000152 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:267 [FINISH] c:0028 p:---- s:0149 e:000148 CFUNC :loop c:0027 p:0005 s:0145 e:000144 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:249 [FINISH] c:0026 p:---- s:0142 e:000141 CFUNC :catch c:0025 p:0010 s:0137 e:000136 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:248 c:0024 p:0050 s:0132 E:000dd8 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:566 c:0023 p:0003 s:0127 e:000126 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:500 [FINISH] c:0022 p:---- s:0124 e:000123 CFUNC :catch c:0021 p:0050 s:0119 E:000d50 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:499 c:0020 p:0069 s:0113 e:000112 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:421 c:0019 p:0012 s:0107 e:000106 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11 [FINISH] c:0018 p:---- s:0104 e:000103 CFUNC :load c:0017 p:0078 s:0099 e:000098 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/irb:25 [FINISH] c:0016 p:---- s:0094 e:000093 CFUNC :load c:0015 p:0064 s:0089 e:000088 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58 c:0014 p:0050 s:0083 e:000082 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23 c:0013 p:0034 s:0078 e:000077 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492 c:0012 p:0054 s:0073 e:000072 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:28 c:0011 p:0040 s:0065 e:000064 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127 c:0010 p:0213 s:0058 e:000057 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:527 c:0009 p:0008 s:0045 e:000044 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34 c:0008 p:0044 s:0040 e:000039 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:584 c:0007 p:0022 s:0033 e:000032 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28 c:0006 p:0042 s:0028 e:000027 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:37 c:0005 p:0007 s:0022 e:000021 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117 c:0004 p:0108 s:0017 E:0019b8 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:29 [FINISH] c:0003 p:---- s:0013 e:000012 CFUNC :load c:0002 p:0081 s:0008 E:000220 EVAL /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/bundle:25 [FINISH] c:0001 p:0000 s:0003 E:001980 DUMMY [FINISH] ``` Sometimes this happens the very first time I try to execute the command, some other times I have to try a couple of times to see that Segmentation Fault (but usually within the first 5 attempts). ---Files-------------------------------- ruby-2023-11-23-175410.ips (20.2 KB) -- https://bugs.ruby-lang.org/
Issue #20020 has been updated by andrea.salicetti@gmail.com (Andrea Salicetti). nobu (Nobuyoshi Nakada) wrote in #note-2:
It seems reproducing only on IRB, but not without IRB.
Actually initially I had the problem running my rspec on Rails 7.0.8. I reported here the easiest reproducible example. ---------------------------------------- Bug #20020: Segfault running regexp match? https://bugs.ruby-lang.org/issues/20020#change-105398 * Author: andrea.salicetti@gmail.com (Andrea Salicetti) * Status: Open * Priority: Normal * ruby -v: 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- **Ruby version** : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] From `irb`, trying to call `match?` on this regular expression causes a segmentation falut: ```ruby irb(main):001:0> /^((a|c)|\s?){1,3}$/.match?('abc') => false irb(main):002:0> /^((a|c)|\s?){1,3}$/.match?('abc') (irb):2: [BUG] Segmentation fault at 0x000000061ba998e8 ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0037 p:---- s:0207 e:000206 CFUNC :match? c:0036 p:0006 s:0202 e:000201 EVAL (irb):2 [FINISH] c:0035 p:---- s:0199 e:000198 CFUNC :eval c:0034 p:0020 s:0191 e:000190 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/workspace.rb:119 c:0033 p:0153 s:0183 e:000181 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/context.rb:502 c:0032 p:0119 s:0170 e:000169 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:588 c:0031 p:0024 s:0164 e:000163 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:777 c:0030 p:0007 s:0158 e:000157 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:567 c:0029 p:0126 s:0153 e:000152 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:267 [FINISH] c:0028 p:---- s:0149 e:000148 CFUNC :loop c:0027 p:0005 s:0145 e:000144 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:249 [FINISH] c:0026 p:---- s:0142 e:000141 CFUNC :catch c:0025 p:0010 s:0137 e:000136 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:248 c:0024 p:0050 s:0132 E:000dd8 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:566 c:0023 p:0003 s:0127 e:000126 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:500 [FINISH] c:0022 p:---- s:0124 e:000123 CFUNC :catch c:0021 p:0050 s:0119 E:000d50 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:499 c:0020 p:0069 s:0113 e:000112 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:421 c:0019 p:0012 s:0107 e:000106 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11 [FINISH] c:0018 p:---- s:0104 e:000103 CFUNC :load c:0017 p:0078 s:0099 e:000098 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/irb:25 [FINISH] c:0016 p:---- s:0094 e:000093 CFUNC :load c:0015 p:0064 s:0089 e:000088 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58 c:0014 p:0050 s:0083 e:000082 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23 c:0013 p:0034 s:0078 e:000077 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492 c:0012 p:0054 s:0073 e:000072 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:28 c:0011 p:0040 s:0065 e:000064 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127 c:0010 p:0213 s:0058 e:000057 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:527 c:0009 p:0008 s:0045 e:000044 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34 c:0008 p:0044 s:0040 e:000039 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:584 c:0007 p:0022 s:0033 e:000032 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28 c:0006 p:0042 s:0028 e:000027 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:37 c:0005 p:0007 s:0022 e:000021 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117 c:0004 p:0108 s:0017 E:0019b8 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:29 [FINISH] c:0003 p:---- s:0013 e:000012 CFUNC :load c:0002 p:0081 s:0008 E:000220 EVAL /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/bundle:25 [FINISH] c:0001 p:0000 s:0003 E:001980 DUMMY [FINISH] ``` Sometimes this happens the very first time I try to execute the command, some other times I have to try a couple of times to see that Segmentation Fault (but usually within the first 5 attempts). ---Files-------------------------------- ruby-2023-11-23-175410.ips (20.2 KB) -- https://bugs.ruby-lang.org/
Issue #20020 has been updated by andrea.salicetti@gmail.com (Andrea Salicetti). Here is a script to reproduce the same in rails/rspec: ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem "rails", "= 7.0.8" gem "rspec" end require "active_record" require "rspec/autorun" class TestCase def matching?(string) /^((a|b|c)|\s?){1,3}$/.match?(string) end end describe TestCase do it 'should work' do expect(described_class.new.matching?('abc')).to be true end it 'should not work' do expect(described_class.new.matching?('xyz')).to be false end end ``` ---------------------------------------- Bug #20020: Segfault running regexp match? https://bugs.ruby-lang.org/issues/20020#change-105399 * Author: andrea.salicetti@gmail.com (Andrea Salicetti) * Status: Open * Priority: Normal * ruby -v: 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- **Ruby version** : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] From `irb`, trying to call `match?` on this regular expression causes a segmentation falut: ```ruby irb(main):001:0> /^((a|c)|\s?){1,3}$/.match?('abc') => false irb(main):002:0> /^((a|c)|\s?){1,3}$/.match?('abc') (irb):2: [BUG] Segmentation fault at 0x000000061ba998e8 ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0037 p:---- s:0207 e:000206 CFUNC :match? c:0036 p:0006 s:0202 e:000201 EVAL (irb):2 [FINISH] c:0035 p:---- s:0199 e:000198 CFUNC :eval c:0034 p:0020 s:0191 e:000190 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/workspace.rb:119 c:0033 p:0153 s:0183 e:000181 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/context.rb:502 c:0032 p:0119 s:0170 e:000169 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:588 c:0031 p:0024 s:0164 e:000163 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:777 c:0030 p:0007 s:0158 e:000157 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:567 c:0029 p:0126 s:0153 e:000152 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:267 [FINISH] c:0028 p:---- s:0149 e:000148 CFUNC :loop c:0027 p:0005 s:0145 e:000144 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:249 [FINISH] c:0026 p:---- s:0142 e:000141 CFUNC :catch c:0025 p:0010 s:0137 e:000136 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:248 c:0024 p:0050 s:0132 E:000dd8 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:566 c:0023 p:0003 s:0127 e:000126 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:500 [FINISH] c:0022 p:---- s:0124 e:000123 CFUNC :catch c:0021 p:0050 s:0119 E:000d50 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:499 c:0020 p:0069 s:0113 e:000112 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:421 c:0019 p:0012 s:0107 e:000106 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11 [FINISH] c:0018 p:---- s:0104 e:000103 CFUNC :load c:0017 p:0078 s:0099 e:000098 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/irb:25 [FINISH] c:0016 p:---- s:0094 e:000093 CFUNC :load c:0015 p:0064 s:0089 e:000088 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58 c:0014 p:0050 s:0083 e:000082 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23 c:0013 p:0034 s:0078 e:000077 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492 c:0012 p:0054 s:0073 e:000072 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:28 c:0011 p:0040 s:0065 e:000064 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127 c:0010 p:0213 s:0058 e:000057 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:527 c:0009 p:0008 s:0045 e:000044 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34 c:0008 p:0044 s:0040 e:000039 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:584 c:0007 p:0022 s:0033 e:000032 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28 c:0006 p:0042 s:0028 e:000027 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:37 c:0005 p:0007 s:0022 e:000021 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117 c:0004 p:0108 s:0017 E:0019b8 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:29 [FINISH] c:0003 p:---- s:0013 e:000012 CFUNC :load c:0002 p:0081 s:0008 E:000220 EVAL /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/bundle:25 [FINISH] c:0001 p:0000 s:0003 E:001980 DUMMY [FINISH] ``` Sometimes this happens the very first time I try to execute the command, some other times I have to try a couple of times to see that Segmentation Fault (but usually within the first 5 attempts). ---Files-------------------------------- ruby-2023-11-23-175410.ips (20.2 KB) -- https://bugs.ruby-lang.org/
Issue #20020 has been updated by wanabe (_ wanabe). Status changed from Open to Closed It has been fixed at 0ac3f2c20e50c22d298238f602f25f84248ac7a5 == https://bugs.ruby-lang.org/issues/19587 == https://github.com/ruby/ruby/pull/7694 . ``` $ git checkout 0ac3f2c20e50c22d298238f602f25f84248ac7a5~ && make -j miniruby >/dev/null 2>&1 && for i in $(seq 1 1 200); do ./miniruby -e '/^((a|c)|\s?){1,3}$/.match?("a")' || break; done HEAD is now at 1b697d7cb5e Constify -e:1: [BUG] Segmentation fault at 0x000060bf044deeda ruby 3.3.0dev (2023-04-12T09:35:32Z v3_3_0_preview1~285 1b697d7cb5) [x86_64-linux] -- Control frame information ----------------------------------------------- c:0003 p:---- s:0011 e:000010 CFUNC :match? c:0002 p:0006 s:0006 e:000005 EVAL -e:1 [FINISH] c:0001 p:0000 s:0003 E:000aa0 DUMMY [FINISH] -- Ruby level backtrace information ---------------------------------------- -e:1:in `<main>' -e:1:in `match?' -- Threading information --------------------------------------------------- Total ractor count: 1 Ruby thread count for this ractor: 1 -- Machine register context ------------------------------------------------ RIP: 0x000055fee5028ad8 RBP: 0x00007fffb1268630 RSP: 0x00007fffb1266670 RAX: 0x0000000000000007 RBX: 0x00000abfe408a8cb RCX: 0x0000000000000003 RDX: 0x0000000000000004 RDI: 0x00000abfe408a8ca RSI: 0x000055ff20454610 R8: 0x000055ff2045465f R9: 0x0000000000000003 R10: 0x000055ff20454653 R11: 0x0000000000000003 R12: 0x00007fffb12686a0 R13: 0x00007a2209c5d838 R14: 0x00007a2209c5d839 R15: 0x000055ff20510b46 EFL: 0x0000000000010202 -- C level backtrace information ------------------------------------------- /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(rb_print_backtrace+0x14) [0x55fee50fe72f] ../../vm_dump.c:785 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(rb_vm_bugreport) ../../vm_dump.c:1101 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(rb_bug_for_fatal_signal+0xec) [0x55fee4ee77ec] ../../error.c:813 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(sigsegv+0x4f) [0x55fee504103f] ../../signal.c:964 /lib/x86_64-linux-gnu/libc.so.6(0x7a2209a45330) [0x7a2209a45330] /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(reset_match_cache+0x1ba) [0x55fee5028ad8] ../../regexec.c:1302 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(match_at) ../../regexec.c:3483 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(onig_search_gpos+0x675) [0x55fee502a745] ../../regexec.c:5176 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(onig_search+0x1a) [0x55fee502af2a] ../../regexec.c:4905 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(rb_reg_match_p+0x110) [0x55fee500e024] ../../re.c:3773 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(rb_reg_match_m_p) ../../re.c:3742 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(vm_cfp_consistent_p+0x0) [0x55fee50d41da] ../../vm_insnhelper.c:3357 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(vm_call_cfunc_with_frame_) ../../vm_insnhelper.c:3359 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(vm_call_cfunc_with_frame) ../../vm_insnhelper.c:3385 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(vm_call_cfunc) ../../vm_insnhelper.c:3482 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(vm_sendish+0x9d) [0x55fee50ee5ba] ../../vm_insnhelper.c:5225 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(vm_exec_core) ../../insns.def:835 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(rb_vm_exec+0x938) [0x55fee50e1608] ../../vm.c:2370 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(rb_ec_exec_node+0xb1) [0x55fee4eecc71] ../../eval.c:287 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(ruby_run_node+0x8b) [0x55fee4ef219b] ../../eval.c:328 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(rb_main+0x21) [0x55fee4e4dc76] ../../main.c:39 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby(main) ../../main.c:58 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_call_main+0x7a) [0x7a2209a2a1ca] ../sysdeps/nptl/libc_start_call_main.h:58 /lib/x86_64-linux-gnu/libc.so.6(call_init+0x0) [0x7a2209a2a28b] ../csu/libc-start.c:360 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main_impl) ../csu/libc-start.c:347 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main) (null):0 [0x55fee4e4dcc5] -- Other runtime information ----------------------------------------------- * Loaded script: -e * Loaded features: 0 enumerator.so 1 thread.rb 2 fiber.so 3 rational.so 4 complex.so 5 ruby2_keywords.rb * Process memory map: 55fee4e06000-55fee4e42000 r--p 00000000 08:30 76290 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby 55fee4e42000-55fee51bd000 r-xp 0003c000 08:30 76290 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby 55fee51bd000-55fee5316000 r--p 003b7000 08:30 76290 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby 55fee5316000-55fee532a000 r--p 00510000 08:30 76290 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby 55fee532a000-55fee532b000 rw-p 00524000 08:30 76290 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby 55fee532b000-55fee533f000 rw-p 00000000 00:00 0 55ff20381000-55ff20578000 rw-p 00000000 00:00 0 [heap] 7a2202c00000-7a2202e07000 r--s 00000000 08:30 1327044 /usr/lib/x86_64-linux-gnu/libc.so.6 7a2203000000-7a2205280000 r--s 00000000 08:30 76290 /home/wanabe/work/prog/ruby/ruby/tmp/master/miniruby 7a22052f0000-7a2205300000 rw-p 00000000 00:00 0 7a2205330000-7a2205380000 rw-p 00000000 00:00 0 7a2205380000-7a2205381000 ---p 00000000 00:00 0 7a2205381000-7a2205422000 rw-p 00000000 00:00 0 7a2205422000-7a2205423000 ---p 00000000 00:00 0 7a2205423000-7a22054c4000 rw-p 00000000 00:00 0 7a22054c4000-7a22054c5000 ---p 00000000 00:00 0 7a22054c5000-7a2205566000 rw-p 00000000 00:00 0 7a2205566000-7a2205567000 ---p 00000000 00:00 0 7a2205567000-7a2205608000 rw-p 00000000 00:00 0 7a2205608000-7a2205609000 ---p 00000000 00:00 0 7a2205609000-7a22056aa000 rw-p 00000000 00:00 0 7a22056aa000-7a22056ab000 ---p 00000000 00:00 0 7a22056ab000-7a220574c000 rw-p 00000000 00:00 0 7a220574c000-7a220574d000 ---p 00000000 00:00 0 7a220574d000-7a22057ee000 rw-p 00000000 00:00 0 7a22057ee000-7a22057ef000 ---p 00000000 00:00 0 7a22057ef000-7a2205890000 rw-p 00000000 00:00 0 7a2205890000-7a2205891000 ---p 00000000 00:00 0 7a2205891000-7a2205932000 rw-p 00000000 00:00 0 7a2205932000-7a2205933000 ---p 00000000 00:00 0 7a2205933000-7a22059d4000 rw-p 00000000 00:00 0 7a22059d4000-7a22059d5000 ---p 00000000 00:00 0 7a22059d5000-7a2205a76000 rw-p 00000000 00:00 0 7a2205a76000-7a2205a77000 ---p 00000000 00:00 0 7a2205a77000-7a2205b18000 rw-p 00000000 00:00 0 7a2205b18000-7a2205b19000 ---p 00000000 00:00 0 7a2205b19000-7a2205bba000 rw-p 00000000 00:00 0 7a2205bba000-7a2205bbb000 ---p 00000000 00:00 0 7a2205bbb000-7a2205c5c000 rw-p 00000000 00:00 0 7a2205c5c000-7a2205c5d000 ---p 00000000 00:00 0 7a2205c5d000-7a2205cfe000 rw-p 00000000 00:00 0 7a2205cfe000-7a2205cff000 ---p 00000000 00:00 0 7a2205cff000-7a2205da0000 rw-p 00000000 00:00 0 7a2205da0000-7a2205da1000 ---p 00000000 00:00 0 7a2205da1000-7a2205e42000 rw-p 00000000 00:00 0 7a2205e42000-7a2205e43000 ---p 00000000 00:00 0 7a2205e43000-7a2205ee4000 rw-p 00000000 00:00 0 7a2205ee4000-7a2205ee5000 ---p 00000000 00:00 0 7a2205ee5000-7a2205f86000 rw-p 00000000 00:00 0 7a2205f86000-7a2205f87000 ---p 00000000 00:00 0 7a2205f87000-7a2206028000 rw-p 00000000 00:00 0 7a2206028000-7a2206029000 ---p 00000000 00:00 0 7a2206029000-7a22060ca000 rw-p 00000000 00:00 0 7a22060ca000-7a22060cb000 ---p 00000000 00:00 0 7a22060cb000-7a220616c000 rw-p 00000000 00:00 0 7a220616c000-7a220616d000 ---p 00000000 00:00 0 7a220616d000-7a220620e000 rw-p 00000000 00:00 0 7a220620e000-7a220620f000 ---p 00000000 00:00 0 7a220620f000-7a22062b0000 rw-p 00000000 00:00 0 7a22062b0000-7a22062b1000 ---p 00000000 00:00 0 7a22062b1000-7a2206352000 rw-p 00000000 00:00 0 7a2206352000-7a2206353000 ---p 00000000 00:00 0 7a2206353000-7a22063f4000 rw-p 00000000 00:00 0 7a22063f4000-7a22063f5000 ---p 00000000 00:00 0 7a22063f5000-7a2206496000 rw-p 00000000 00:00 0 7a2206496000-7a2206497000 ---p 00000000 00:00 0 7a2206497000-7a2206538000 rw-p 00000000 00:00 0 7a2206538000-7a2206539000 ---p 00000000 00:00 0 7a2206539000-7a22065da000 rw-p 00000000 00:00 0 7a22065da000-7a22065db000 ---p 00000000 00:00 0 7a22065db000-7a220667c000 rw-p 00000000 00:00 0 7a220667c000-7a220667d000 ---p 00000000 00:00 0 7a220667d000-7a220671e000 rw-p 00000000 00:00 0 7a220671e000-7a220671f000 ---p 00000000 00:00 0 7a220671f000-7a22067c0000 rw-p 00000000 00:00 0 7a22067c0000-7a22067f0000 rw-p 00000000 00:00 0 7a22067f7000-7a2209800000 rw-p 00000000 00:00 0 7a220980f000-7a22098a0000 rw-p 00000000 00:00 0 7a22098a6000-7a22099a7000 rw-p 00000000 00:00 0 7a22099a7000-7a2209a00000 r--p 00000000 08:30 226342 /usr/lib/locale/C.utf8/LC_CTYPE 7a2209a00000-7a2209a28000 r--p 00000000 08:30 1327044 /usr/lib/x86_64-linux-gnu/libc.so.6 7a2209a28000-7a2209bb0000 r-xp 00028000 08:30 1327044 /usr/lib/x86_64-linux-gnu/libc.so.6 7a2209bb0000-7a2209bff000 r--p 001b0000 08:30 1327044 /usr/lib/x86_64-linux-gnu/libc.so.6 7a2209bff000-7a2209c03000 r--p 001fe000 08:30 1327044 /usr/lib/x86_64-linux-gnu/libc.so.6 7a2209c03000-7a2209c05000 rw-p 00202000 08:30 1327044 /usr/lib/x86_64-linux-gnu/libc.so.6 7a2209c05000-7a2209c12000 rw-p 00000000 00:00 0 7a2209c30000-7a2209c60000 rw-p 00000000 00:00 0 7a2209c66000-7a2209d87000 r--p 00000000 08:30 35036 /usr/lib/locale/locale-archive 7a2209d87000-7a2209d8c000 rw-p 00000000 00:00 0 7a2209d8c000-7a2209d90000 r--p 00000000 08:30 1948819 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 7a2209d90000-7a2209db4000 r-xp 00004000 08:30 1948819 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 7a2209db4000-7a2209db8000 r--p 00028000 08:30 1948819 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 7a2209db8000-7a2209db9000 r--p 0002b000 08:30 1948819 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 7a2209db9000-7a2209dba000 rw-p 0002c000 08:30 1948819 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 7a2209dba000-7a2209dca000 r--p 00000000 08:30 1327047 /usr/lib/x86_64-linux-gnu/libm.so.6 7a2209dca000-7a2209e49000 r-xp 00010000 08:30 1327047 /usr/lib/x86_64-linux-gnu/libm.so.6 7a2209e49000-7a2209ea1000 r--p 0008f000 08:30 1327047 /usr/lib/x86_64-linux-gnu/libm.so.6 7a2209ea1000-7a2209ea2000 r--p 000e7000 08:30 1327047 /usr/lib/x86_64-linux-gnu/libm.so.6 7a2209ea2000-7a2209ea3000 rw-p 000e8000 08:30 1327047 /usr/lib/x86_64-linux-gnu/libm.so.6 7a2209ea3000-7a2209ea5000 r--p 00000000 08:30 12696 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0 7a2209ea5000-7a2209eba000 r-xp 00002000 08:30 12696 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0 7a2209eba000-7a2209ed3000 r--p 00017000 08:30 12696 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0 7a2209ed3000-7a2209ed4000 r--p 0002f000 08:30 12696 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0 7a2209ed4000-7a2209ed5000 rw-p 00030000 08:30 12696 /usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0 7a2209ed5000-7a2209edd000 rw-p 00000000 00:00 0 7a2209edd000-7a2209ee7000 r--p 00000000 08:30 12800 /usr/lib/x86_64-linux-gnu/libgmp.so.10.5.0 7a2209ee7000-7a2209f4a000 r-xp 0000a000 08:30 12800 /usr/lib/x86_64-linux-gnu/libgmp.so.10.5.0 7a2209f4a000-7a2209f5f000 r--p 0006d000 08:30 12800 /usr/lib/x86_64-linux-gnu/libgmp.so.10.5.0 7a2209f5f000-7a2209f60000 r--p 00081000 08:30 12800 /usr/lib/x86_64-linux-gnu/libgmp.so.10.5.0 7a2209f60000-7a2209f61000 rw-p 00082000 08:30 12800 /usr/lib/x86_64-linux-gnu/libgmp.so.10.5.0 7a2209f61000-7a2209f63000 r--p 00000000 08:30 13086 /usr/lib/x86_64-linux-gnu/libz.so.1.3 7a2209f63000-7a2209f75000 r-xp 00002000 08:30 13086 /usr/lib/x86_64-linux-gnu/libz.so.1.3 7a2209f75000-7a2209f7b000 r--p 00014000 08:30 13086 /usr/lib/x86_64-linux-gnu/libz.so.1.3 7a2209f7b000-7a2209f7c000 r--p 0001a000 08:30 13086 /usr/lib/x86_64-linux-gnu/libz.so.1.3 7a2209f7c000-7a2209f7d000 rw-p 0001b000 08:30 13086 /usr/lib/x86_64-linux-gnu/libz.so.1.3 7a2209f80000-7a2209f87000 r--s 00000000 08:30 1327032 /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache 7a2209f87000-7a2209f89000 rw-p 00000000 00:00 0 7a2209f89000-7a2209f8d000 r--p 00000000 00:00 0 [vvar] 7a2209f8d000-7a2209f8f000 r--p 00000000 00:00 0 [vvar_vclock] 7a2209f8f000-7a2209f91000 r-xp 00000000 00:00 0 [vdso] 7a2209f91000-7a2209f92000 r--p 00000000 08:30 1327041 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 7a2209f92000-7a2209fbd000 r-xp 00001000 08:30 1327041 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 7a2209fbd000-7a2209fc7000 r--p 0002c000 08:30 1327041 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 7a2209fc7000-7a2209fc9000 r--p 00036000 08:30 1327041 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 7a2209fc9000-7a2209fcb000 rw-p 00038000 08:30 1327041 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 7fffb0a6d000-7fffb126c000 rw-p 00000000 00:00 0 [stack] Aborted (core dumped) $ git checkout 0ac3f2c20e50c22d298238f602f25f84248ac7a5 && make -j miniruby >/dev/null 2>&1 && for i in $(seq 1 1 200); do ./miniruby -e '/^((a|c)|\s?){1,3}$/.match?("a")' || bre ak; done Previous HEAD position was 1b697d7cb5e Constify HEAD is now at 0ac3f2c20e5 [Bug #19587] Fix `reset_match_cache` arguments $ ``` ---------------------------------------- Bug #20020: Segfault running regexp match? https://bugs.ruby-lang.org/issues/20020#change-118628 * Author: andrea.salicetti@gmail.com (Andrea Salicetti) * Status: Closed * ruby -v: 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- **Ruby version** : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] From `irb`, trying to call `match?` on this regular expression causes a segmentation falut: ```ruby irb(main):001:0> /^((a|c)|\s?){1,3}$/.match?('abc') => false irb(main):002:0> /^((a|c)|\s?){1,3}$/.match?('abc') (irb):2: [BUG] Segmentation fault at 0x000000061ba998e8 ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin23] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0037 p:---- s:0207 e:000206 CFUNC :match? c:0036 p:0006 s:0202 e:000201 EVAL (irb):2 [FINISH] c:0035 p:---- s:0199 e:000198 CFUNC :eval c:0034 p:0020 s:0191 e:000190 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/workspace.rb:119 c:0033 p:0153 s:0183 e:000181 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/context.rb:502 c:0032 p:0119 s:0170 e:000169 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:588 c:0031 p:0024 s:0164 e:000163 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:777 c:0030 p:0007 s:0158 e:000157 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:567 c:0029 p:0126 s:0153 e:000152 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:267 [FINISH] c:0028 p:---- s:0149 e:000148 CFUNC :loop c:0027 p:0005 s:0145 e:000144 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:249 [FINISH] c:0026 p:---- s:0142 e:000141 CFUNC :catch c:0025 p:0010 s:0137 e:000136 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ruby-lex.rb:248 c:0024 p:0050 s:0132 E:000dd8 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:566 c:0023 p:0003 s:0127 e:000126 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:500 [FINISH] c:0022 p:---- s:0124 e:000123 CFUNC :catch c:0021 p:0050 s:0119 E:000d50 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:499 c:0020 p:0069 s:0113 e:000112 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:421 c:0019 p:0012 s:0107 e:000106 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11 [FINISH] c:0018 p:---- s:0104 e:000103 CFUNC :load c:0017 p:0078 s:0099 e:000098 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/irb:25 [FINISH] c:0016 p:---- s:0094 e:000093 CFUNC :load c:0015 p:0064 s:0089 e:000088 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58 c:0014 p:0050 s:0083 e:000082 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23 c:0013 p:0034 s:0078 e:000077 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492 c:0012 p:0054 s:0073 e:000072 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:28 c:0011 p:0040 s:0065 e:000064 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127 c:0010 p:0213 s:0058 e:000057 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:527 c:0009 p:0008 s:0045 e:000044 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34 c:0008 p:0044 s:0040 e:000039 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:584 c:0007 p:0022 s:0033 e:000032 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28 c:0006 p:0042 s:0028 e:000027 BLOCK /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:37 c:0005 p:0007 s:0022 e:000021 METHOD /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117 c:0004 p:0108 s:0017 E:0019b8 TOP /Users/andreasalicetti/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.22/exe/bundle:29 [FINISH] c:0003 p:---- s:0013 e:000012 CFUNC :load c:0002 p:0081 s:0008 E:000220 EVAL /Users/andreasalicetti/.rbenv/versions/3.2.2/bin/bundle:25 [FINISH] c:0001 p:0000 s:0003 E:001980 DUMMY [FINISH] ``` Sometimes this happens the very first time I try to execute the command, some other times I have to try a couple of times to see that Segmentation Fault (but usually within the first 5 attempts). ---Files-------------------------------- ruby-2023-11-23-175410.ips (20.2 KB) -- https://bugs.ruby-lang.org/
participants (4)
-
andrea.salicetti@gmail.com (Andrea Salicetti) -
nobu (Nobuyoshi Nakada) -
rubyFeedback (robert heiler) -
wanabe (_ wanabe)