Project

General

Profile

Actions

Bug #22002

closed

argument stack underflow (-1)

Bug #22002: argument stack underflow (-1)

Added by anonymous128 (Droid 00000) about 21 hours ago. Updated about 8 hours ago.

Status:
Closed
Assignee:
Target version:
-
ruby -v:
ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
[ruby-core:125274]

Description

The following lines of code:

sleep(0.1) until defined?(@variable)

@variable

produce this error:

home@My-Air testing % bundle exec ruby test.rb
-- raw disasm--------
   trace: 1
   0000 jump                 <L000>                                      (   1)
 <L004> [sp: 0, unremovable: 1, refcnt: 1]
   0002 putnil                                                           (   1)
 <L005> [sp: 1, unremovable: 0, refcnt: 1]
   0003 pop                                                              (   1)
   0004 jump                 <L000>                                      (   1)
 <L001> [sp: 0, unremovable: 1, refcnt: 5]
   0006 putself                                                          (   1)
   0007 putobject            0.1                                         (   1)
   0009 opt_send_without_block <calldata:sleep, 1>                       (   1)
   0011 pop                                                              (   1)
 <L000> [sp: 0, unremovable: 0, refcnt: 2]
 <L012> [sp: 0, unremovable: 0, refcnt: 0]
*  0012 branchunless         <L001>                                      (   1)
   adjust: [label: 4]
   0014 putnil                                                           (   1)
 <L002> [sp: -1, unremovable: 0, refcnt: 4]
   0015 pop                                                              (   1)
   trace: 1
   0016 getinstancevariable  :@variable, <ivc:0>                         (   3)
   0019 leave                                                            (   3)
---------------------
test.rb:1: argument stack underflow (-1)
test.rb: compile error (SyntaxError)

Updated by byroot (Jean Boussier) about 17 hours ago Actions #1 [ruby-core:125275]

  • Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: DONTNEED, 3.4: REQUIRED, 4.0: REQUIRED

I can repro on both 3.4 and 4.0.

Updated by Earlopain (Earlopain _) about 10 hours ago Actions #2 [ruby-core:125277]

  • Assignee set to prism

It's a prism-specific issue and there are a few other usages that cause a similar result that I found. I fixed those in https://github.com/ruby/ruby/pull/16750

Updated by Earlopain (Earlopain _) about 8 hours ago Actions #3

  • Status changed from Open to Closed

Applied in changeset git|d077df24a2256d760cc534b242b28822d4ef6376.


[Bug #22002] Never pop when compiling branch predicate

The value is always needed. Now prism emits the same instructions as parse.y for the added test case.

defined?/flip-flop caused argument stack underflow, and/or segfaulted during runtime.

Actions

Also available in: PDF Atom