
Issue #20926 has been reported by tenderlovemaking (Aaron Patterson). ---------------------------------------- Bug #20926: shareable_constant_value: experimental_everything crashes with parse.y https://bugs.ruby-lang.org/issues/20926 * Author: tenderlovemaking (Aaron Patterson) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- This program crashes with parse.y as the parser: ``` ./miniruby --dump=insns --parser=parse.y -v -e'# shareable_constant_value: experimental_everything C = { **{ } }' ``` Backtrace from LLDB looks like this: ``` (lldb) run Process 66489 launched: '/Users/aaron/git/ruby/miniruby' (arm64) Process 66489 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3523922faa9c0058) frame #0: 0x0000000100220f84 miniruby`RB_BUILTIN_TYPE(obj=3829064841618522200) at value_type.h:191:30 188 * RB_SPECIAL_CONST_P check. */ 189 __asm volatile("": : :"memory"); 190 #endif -> 191 VALUE ret = RBASIC(obj)->flags & RUBY_T_MASK; 192 return RBIMPL_CAST((enum ruby_value_type)ret); 193 } 194 Target 0: (miniruby) stopped. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3523922faa9c0058) * frame #0: 0x0000000100220f84 miniruby`RB_BUILTIN_TYPE(obj=3829064841618522200) at value_type.h:191:30 frame #1: 0x0000000100220e84 miniruby`RCLASS_SINGLETON_P [inlined] rbimpl_RB_TYPE_P_fastpath(obj=3829064841618522200, t=RUBY_T_CLASS) at value_type.h:352:19 frame #2: 0x0000000100220d0c miniruby`RCLASS_SINGLETON_P(klass=3829064841618522200) at class.h:202:12 frame #3: 0x0000000100220c80 miniruby`rb_class_real(cl=3829064841618522200) at object.c:290:10 frame #4: 0x0000000100220fd8 miniruby`rb_obj_class(obj=6171908688) at object.c:299:12 frame #5: 0x0000000100172218 miniruby`rb_hash_aset(hash=4367092992, key=6171908688, val=4367092800) at hash.c:2931:10 frame #6: 0x0000000100090a1c miniruby`compile_shareable_literal_constant(iseq=0x00000001043e10d0, ret=0x000000016fdfdad8, shareable=rb_parser_shareable_everything, dest=0x000000014c7c5468, node=0x000000014c7c5548, level=0, value_p=0x000000016fdfdac8, shareable_literal_p=0x000000016fdfdad4) at compile.c:10507:21 frame #7: 0x000000010007db5c miniruby`compile_shareable_constant_value(iseq=0x00000001043e10d0, ret=0x000000016fdfe518, shareable=rb_parser_shareable_everything, lhs=0x000000014c7c5468, value=0x000000014c7c5548) at compile.c:10591:9 frame #8: 0x0000000100073e10 miniruby`iseq_compile_each0(iseq=0x00000001043e10d0, ret=0x000000016fdfe518, node=0x000000014c7c5468, popped=0) at compile.c:10786:13 frame #9: 0x0000000100057354 miniruby`iseq_compile_each(iseq=0x00000001043e10d0, ret=0x000000016fdfe518, node=0x000000014c7c5468, popped=0) at compile.c:10624:12 frame #10: 0x0000000100056f0c miniruby`rb_iseq_compile_node(iseq=0x00000001043e10d0, node=0x000000014c7c5578) at compile.c:919:13 frame #11: 0x00000001001b8cbc miniruby`rb_iseq_new_with_opt(ast_value=4366143936, name=4343347824, path=4343499984, realpath=4366954464, first_lineno=0, parent=0x0000000102e23a40, isolated_depth=0, type=ISEQ_TYPE_MAIN, option=0x000000016fdfe648, script_lines=4) at iseq.c:1011:5 frame #12: 0x00000001001b9230 miniruby`rb_iseq_new_main(ast_value=4366143936, path=4343499984, realpath=4366954464, parent=0x0000000102e23a40, opt=1) at iseq.c:915:12 frame #13: 0x000000010031715c miniruby`process_options(argc=0, argv=0x000000016fdff5d8, opt=0x000000016fdff0e0) at ruby.c:2627:20 frame #14: 0x0000000100316000 miniruby`ruby_process_options(argc=3, argv=0x000000016fdff5c0) at ruby.c:3169:12 frame #15: 0x00000001001260a8 miniruby`ruby_options(argc=3, argv=0x000000016fdff5c0) at eval.c:117:16 frame #16: 0x0000000100001940 miniruby`rb_main(argc=3, argv=0x000000016fdff5c0) at main.c:43:26 frame #17: 0x00000001000018cc miniruby`main(argc=3, argv=0x000000016fdff5c0) at main.c:68:12 frame #18: 0x0000000199240274 dyld`start + 2840 ``` I think the program is supposed to emit instructions that look like this: ``` $ ruby -v --dump=insns test.rb ruby 3.3.4 (2024-07-16 revision 425e468d25) [arm64-darwin23] == disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)> 0000 putobject {nil=>{}} ( 3)[Li] 0002 dup 0003 putspecialobject 3 0005 setconstant :C 0007 leave ``` -- https://bugs.ruby-lang.org/