From: "steviejj (Steven Johnstone) via ruby-core" Date: 2026-11-17T14:29:15+00:00 Subject: [ruby-core:127556] [Ruby Bug#22557] parse.y segmentation fault parsing malformed nested case Issue #22557 has been reported by steviejj (Steven Johnstone). ---------------------------------------- Bug #22557: parse.y segmentation fault parsing malformed nested case https://bugs.ruby-lang.org/issues/22557 * Author: steviejj (Steven Johnstone) * Status: Open * ruby -v: ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin27] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Prism gives syntax errors: ``` ruby --parser=prism -ce 'case; when 1; case; value; in 1; end; end' ruby: -e:1: syntax errors found (SyntaxError) > 1 | case; when 1; case; value; in 1; end; end | ^~~~ expected an `end` to close the `case` statement | ^~~~ expected a `when` or `in` clause after `case` | ^~~~ expected a predicate for a case matching statement | ^~~~~ unexpected local variable or method, expecting end-of-input | ^~ unexpected 'in', ignoring it | ^~~ unexpected 'end', ignoring it ``` Parse.y segfaults: ``` ruby --parser=parse.y -ce 'case; when 1; case; value; in 1; end; end' -e:1: syntax error, unexpected local variable or method, expecting 'when' case; when 1; case; value; in 1; end; end ruby: [BUG] Segmentation fault at 0x0000000000000019 ruby 4.0.9 (2026-10-23 revision 3e93b23afc) [arm64-darwin27] -- 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:0001 p:0000 s:0003 E:0022c0 l:y b:---- DUMMY [FINISH] -- Threading information --------------------------------------------------- Total ractor count: 1 Ruby thread count for this ractor: 1 -- Machine register context ------------------------------------------------ x0: 0x0000000000000001 x1: 0x0000000103ab54c4 x2: 0x000000016d120710 x3: 0x0000000000000000 x4: 0x0000000000000001 x5: 0x0000000000000000 x6: 0x0000000000000001 x7: 0xffffffffb00007ff x18: 0x0000000000000000 x19: 0x0000000000000001 x20: 0x000000000000017a x21: 0x000000016d121490 x22: 0x000000016d120840 x23: 0x000000000000011e x24: 0x000000016d121aac x25: 0x00000000000000c8 x26: 0x00000000000003ca x27: 0x0000000103afc902 x28: 0x0000000103ab3dd2 lr: 0x00000001037b048c fp: 0x000000016d1205f0 sp: 0x000000016d1205e0 -- C level backtrace information ------------------------------------------- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_vm_bugreport+0x374) [0x1038a3a2c] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_bug_for_fatal_signal) [0x10372e198] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(sigabrt) [0x10382016c] /usr/lib/system/libsystem_platform.dylib(_sigtramp+0x38) [0x18bcac144] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(ruby_yyparse) [0x1037b048c] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(ruby_yyparse) [0x1037b048c] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(yycompile0) [0x1037b9358] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_suppress_tracing) [0x1038a4fb4] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_parser_compile) [0x1037b7ba8] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(parser_compile) [0x103816328] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(rb_parser_compile_string) [0x103815704] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(ruby_process_options) [0x1038112ac] /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib(ruby_options) [0x103734f20] /opt/homebrew/Cellar/ruby/4.0.9/bin/ruby(main+0x64) [0x102cdd5a4] -- Other runtime information ----------------------------------------------- * Loaded script: ruby * Ruby Box: disabled * Loaded features: 0 enumerator.so 1 thread.rb 2 fiber.so 3 rational.so 4 complex.so 5 pathname.so 6 ruby2_keywords.rb 7 set.rb 8 /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/enc/encdb.bundle 9 /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/enc/trans/transdb.bundle * Process memory map: 102cf0000-102cf8000 r-- /opt/homebrew/Cellar/ruby/4.0.9/bin/ruby 102cf8000-102cfc000 r-- /opt/homebrew/Cellar/ruby/4.0.9/bin/ruby 102cfc000-102d3c000 rw- /opt/homebrew/Cellar/ruby/4.0.9/bin/ruby 102f48000-102fc8000 --- /usr/lib/system/libsystem_platform.dylib 102fc8000-1030ac000 rw- /usr/lib/system/libsystem_platform.dylib 1030ac000-1030b0000 r-- /usr/lib/system/libsystem_platform.dylib 1030b0000-1030b8000 rw- /usr/lib/system/libsystem_platform.dylib 1030c8000-103368000 --- /usr/lib/system/libsystem_platform.dylib 103368000-1033c0000 rw- /usr/lib/system/libsystem_platform.dylib 1033c0000-103440000 rw- /usr/lib/system/libsystem_platform.dylib 103e10000-103e14000 --- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 103e14000-104214000 rw- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 104214000-104218000 --- /opt/homebrew/Cellar/ruby/4.0.9/lib/libruby.4.0.dylib 133e00000-133e04000 rw- 7620800000-7620c00000 rw- 7620c00000-7621000000 rw- 7621000000-7621400000 rw- 7621400000-7621800000 rw- 7621800000-7621c00000 rw- 7a4c000000-7a4c400000 rw- [IMPORTANT] Don't forget to include the Crash Report log file under DiagnosticReports directory in bug reports. ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/