From: "steviejj (Steven Johnstone) via ruby-core" Date: 2026-11-17T15:09:43+00:00 Subject: [ruby-core:127559] [Ruby Bug#22560] parse.y hits UNREACHABLE_RETURN(0) after compile_error in rb_parser_enc_cr_str_buf_cat Issue #22560 has been reported by steviejj (Steven Johnstone). ---------------------------------------- Bug #22560: parse.y hits UNREACHABLE_RETURN(0) after compile_error in rb_parser_enc_cr_str_buf_cat https://bugs.ruby-lang.org/issues/22560 * 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 ---------------------------------------- In CRuby's `parse.y`, `rb_parser_enc_cr_str_buf_cat` calls non-fatal `compile_error(p, "incompatible character encodings: ...")` (`parser_compile_error` / `ripper_compile_error`) followed immediately by `UNREACHABLE_RETURN(0)` (`__builtin_unreachable()`). Because `compile_error` appends the syntax error and **returns normally** rather than longjmping, control flow falls off `__builtin_unreachable()` into undefined code. This is reliably triggered by `tokadd_utf8` / `tokadd_codepoint` passing a hardcoded `rb_utf8_encoding()` instead of `p->enc` to `flush_string_content` on an invalid or unterminated `\u{...}` escape inside an `ASCII-8BIT` string literal spanning a newline (`p->delayed.token`). ``` ruby -e 'STDOUT.binmode; STDOUT.write("#coding:ascii-8bit\n\"\x80\n\x80\\u{0")' > foo.rb ��� lldb ruby (lldb) target create "ruby" Current executable set to '/opt/homebrew/opt/ruby/bin/ruby' (arm64). (lldb) run --parser=parse.y foo.rb Process 19325 launched: '/opt/homebrew/opt/ruby/bin/ruby' (arm64) warning: (arm64) /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/enc/encdb.bundle empty dSYM file detected, dSYM was created with an executable with no debug info. warning: (arm64) /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/enc/trans/transdb.bundle empty dSYM file detected, dSYM was created with an executable with no debug info. warning: (arm64) /opt/homebrew/Cellar/ruby/4.0.9/lib/ruby/4.0.0/arm64-darwin27/monitor.bundle empty dSYM file detected, dSYM was created with an executable with no debug info. Process 19325 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1009eae78) frame #0: 0x00000001009eae78 libruby.4.0.dylib`rb_parser_enc_cr_str_buf_cat + 432 libruby.4.0.dylib`rb_parser_enc_cr_str_buf_cat: -> 0x1009eae78 <+432>: brk #0x1 libruby.4.0.dylib`parser_yylex: 0x1009eae7c <+0>: sub sp, sp, #0xf0 0x1009eae80 <+4>: stp x28, x27, [sp, #0x90] 0x1009eae84 <+8>: stp x26, x25, [sp, #0xa0] Target 0: (ruby) stopped. ``` -- 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/