From: "Earlopain (Earlopain _) via ruby-core" Date: 2025-10-27T12:23:01+00:00 Subject: [ruby-core:123547] [Ruby Bug#21648] [prism] ruby crashes for `for * in [10]; end` Issue #21648 has been updated by Earlopain (Earlopain _). https://github.com/ruby/ruby/pull/14963 ---------------------------------------- Bug #21648: [prism] ruby crashes for `for * in [10]; end` https://bugs.ruby-lang.org/issues/21648#change-114925 * Author: Earlopain (Earlopain _) * Status: Open * ruby -v: ruby 3.4.6 (2025-09-16 revision dbd83256b1) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- ```sh $ ruby -e "for * in [10]; end" -e:1: [BUG] Stack consistency error (sp: 15, bp: 14) ruby 3.4.6 (2025-09-16 revision dbd83256b1) +PRISM [x86_64-linux] -- Control frame information ----------------------------------------------- c:0004 p:0008 s:0015 e:000013 BLOCK -e:1 [FINISH] c:0003 p:---- s:0010 e:000009 CFUNC :each c:0002 p:0005 s:0006 e:000005 EVAL -e:1 [FINISH] c:0001 p:0000 s:0003 E:0014c0 DUMMY [FINISH] ... ``` `parse.y` handles this. Seems like this is getting miscompiled somewhere: ```diff diff --git a/test.txt b/test.txt index d1c4ff74..5f2616e4 100644 --- a/test.txt +++ b/test.txt @@ -1,4 +1,4 @@ -ruby --dump=insn -e "for * in [10]; end" +$ ruby --parser=parse.y --dump=insn -e "for * in [10]; end" == disasm: #@-e:1 (1,0)-(1,18)> 0000 duparray [10] ( 1)[Li] 0002 send , block in
@@ -8,7 +8,22 @@ ruby --dump=insn -e "for * in [10]; end" local table (size: 1, argc: 0 [opts: 0, rest: 0, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] ?@0 0000 getlocal_WC_0 ?@0 ( 1) -0002 expandarray 1, 0 -0005 nop [Bc] -0006 putnil -0007 leave [Br] +0002 dup +0003 opt_length [CcCr] +0005 putobject_INT2FIX_1_ +0006 opt_eq [CcCr] +0008 branchunless 24 +0010 dup +0011 putobject_INT2FIX_0_ +0012 opt_aref [CcCr] +0014 putobject Array +0016 swap +0017 opt_send_without_block +0019 dup +0020 branchunless 23 +0022 swap +0023 pop +0024 expandarray 0, 0 +0027 nop [Bc] +0028 putnil +0029 leave [Br] ``` ---Files-------------------------------- crash.txt (19.7 KB) -- 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/