Skip to content

Add pushtoarray insn to fix segfault with forwarding + splat#15855

Merged
tenderlove merged 1 commit intoruby:masterfrom
Shopify:rwstauner/fix-fwd-splat
Jan 13, 2026
Merged

Add pushtoarray insn to fix segfault with forwarding + splat#15855
tenderlove merged 1 commit intoruby:masterfrom
Shopify:rwstauner/fix-fwd-splat

Conversation

@rwstauner
Copy link
Copy Markdown
Contributor

@rwstauner rwstauner commented Jan 13, 2026

Example insns diff for def x = [3]; def a(...) = b(*x, 2, 3, ...)

 == disasm: #<ISeq:a@-e:1 (1,13)-(1,42)>
 local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
 [ 1] "..."@0
 0000 putself                                                          (   1)[Ca]
 0000 putself
 0000 opt_send_without_block                 <calldata!mid:x, argc:0, FCALL|VCALL|ARGS_SIMPLE>
 0000 splatarray                             true
 0000 putobject                              2
 0000 putobject                              3
+0000 pushtoarray                            2
 0000 getlocal_WC_0                          "..."@0
 0000 sendforward                            <calldata!mid:b, argc:1, ARGS_SPLAT|ARGS_SPLAT_MUT|FCALL|FORWARDING>, nil
 0000 leave                                  [Re]

This matches the insns produced by parse.y

@rwstauner rwstauner marked this pull request as ready for review January 13, 2026 02:08
@rwstauner rwstauner force-pushed the rwstauner/fix-fwd-splat branch 3 times, most recently from 8f24e66 to 6abc659 Compare January 13, 2026 02:14
@Earlopain
Copy link
Copy Markdown
Contributor

Can you also update the comment above to include the forwarding case? Otherwise this looks OK to me. cc @kddnewton (https://bugs.ruby-lang.org/issues/21832)

@rwstauner rwstauner force-pushed the rwstauner/fix-fwd-splat branch 2 times, most recently from 5566d9e to 70626fb Compare January 13, 2026 14:59
Example insns diff for `def x = [3]; def a(...) = b(*x, 2, 3, ...)`

     == disasm: #<ISeq:a@-e:1 (1,13)-(1,42)>
     local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
     [ 1] "..."@0
     0000 putself                                                          (   1)[Ca]
     0000 putself
     0000 opt_send_without_block                 <calldata!mid:x, argc:0, FCALL|VCALL|ARGS_SIMPLE>
     0000 splatarray                             true
     0000 putobject                              2
     0000 putobject                              3
    +0000 pushtoarray                            2
     0000 getlocal_WC_0                          "..."@0
     0000 sendforward                            <calldata!mid:b, argc:1, ARGS_SPLAT|ARGS_SPLAT_MUT|FCALL|FORWARDING>, nil
     0000 leave                                  [Re]

This matches the insns produced by parse.y
@rwstauner rwstauner force-pushed the rwstauner/fix-fwd-splat branch from 70626fb to 638aea1 Compare January 13, 2026 15:01
Copy link
Copy Markdown
Member

@tenderlove tenderlove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@tenderlove tenderlove merged commit 1a0b356 into ruby:master Jan 13, 2026
101 of 104 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants