Project

General

Profile

Bug #13682

return inside of ensure causes [BUG]

Added by shyouhei (Shyouhei Urabe) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-06-27 trunk 59146) [x86_64-darwin15]
[ruby-core:81777]

Description

Attached script causes [BUG] Stack consistency error (sp: 7, bp: 6)


Files

bug.rb (36 Bytes) bug.rb shyouhei (Shyouhei Urabe), 06/27/2017 04:02 AM

Related issues

Related to Ruby master - Feature #4840: Allow returning from requireClosedActions

Associated revisions

Revision 1474acff
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fix return in toplevel rescue/ensure

  • compile.c (iseq_compile_each0): throw TAG_RETURN at return in
    toplevel rescue/ensure to adjust VM stack properly.
    [ruby-core:81777] [Bug #13682]

  • vm_insnhelper.c (vm_throw_start): allow return in toplevel
    rescue/ensure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59183
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fix return in toplevel rescue/ensure

  • compile.c (iseq_compile_each0): throw TAG_RETURN at return in
    toplevel rescue/ensure to adjust VM stack properly.
    [ruby-core:81777] [Bug #13682]

  • vm_insnhelper.c (vm_throw_start): allow return in toplevel
    rescue/ensure.

Revision 59183
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fix return in toplevel rescue/ensure

  • compile.c (iseq_compile_each0): throw TAG_RETURN at return in
    toplevel rescue/ensure to adjust VM stack properly.
    [ruby-core:81777] [Bug #13682]

  • vm_insnhelper.c (vm_throw_start): allow return in toplevel
    rescue/ensure.

Revision 59183
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fix return in toplevel rescue/ensure

  • compile.c (iseq_compile_each0): throw TAG_RETURN at return in
    toplevel rescue/ensure to adjust VM stack properly.
    [ruby-core:81777] [Bug #13682]

  • vm_insnhelper.c (vm_throw_start): allow return in toplevel
    rescue/ensure.

Revision 5cfda379
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fix return in toplevel ensure

  • compile.c (iseq_compile_each0): adjust stack after return in toplevel ensure, when the value is used. [ruby-core:81777] [Bug #13682]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59184
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fix return in toplevel ensure

  • compile.c (iseq_compile_each0): adjust stack after return in toplevel ensure, when the value is used. [ruby-core:81777] [Bug #13682]

Revision 59184
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fix return in toplevel ensure

  • compile.c (iseq_compile_each0): adjust stack after return in toplevel ensure, when the value is used. [ruby-core:81777] [Bug #13682]

Revision 59184
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fix return in toplevel ensure

  • compile.c (iseq_compile_each0): adjust stack after return in toplevel ensure, when the value is used. [ruby-core:81777] [Bug #13682]

Revision 91b51140
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 59183,59184: [Backport #13682]

    fix return in toplevel rescue/ensure

    * compile.c (iseq_compile_each0): throw TAG_RETURN at return in
      toplevel rescue/ensure to adjust VM stack properly.
      [ruby-core:81777] [Bug #13682]

    * vm_insnhelper.c (vm_throw_start): allow return in toplevel
      rescue/ensure.
    fix return in toplevel ensure

    * compile.c (iseq_compile_each0): adjust stack after return in
      toplevel ensure, when the value is used.
      [ruby-core:81777] [Bug #13682]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59493
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 59183,59184: [Backport #13682]

fix return in toplevel rescue/ensure

* compile.c (iseq_compile_each0): throw TAG_RETURN at return in
  toplevel rescue/ensure to adjust VM stack properly.
  [ruby-core:81777] [Bug #13682]

* vm_insnhelper.c (vm_throw_start): allow return in toplevel
  rescue/ensure.
fix return in toplevel ensure

* compile.c (iseq_compile_each0): adjust stack after return in
  toplevel ensure, when the value is used.
  [ruby-core:81777] [Bug #13682]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r59183.


fix return in toplevel rescue/ensure

  • compile.c (iseq_compile_each0): throw TAG_RETURN at return in
    toplevel rescue/ensure to adjust VM stack properly.
    [ruby-core:81777] [Bug #13682]

  • vm_insnhelper.c (vm_throw_start): allow return in toplevel
    rescue/ensure.

Updated by shyouhei (Shyouhei Urabe) over 2 years ago

  • Status changed from Closed to Open

Seems incomplete.

% ./miniruby -ve 'begin raise ensure return end and self'
ruby 2.5.0dev (2017-06-27 trunk 59183) [x86_64-darwin15]
-- raw disasm--------
 [none]
 0000 trace                1                                           (   1)
 <L001>
 0002 putself                                                          (   1)
 0003 opt_send_without_block <callinfo:raise, 0>, <call cache>         (   1)
 0006 pop                                                              (   1)
 <L002>
 adjust: [label: -1]
 0007 putnil                                                           (   1)
 0008 leave                                                            (   1)
 <L003>
 0009 pop                                                              (   1)
 0010 dup                                                              (   1)
 0011 branchunless         <L000>                                      (   1)
*0013 pop                                                              (   1)
 0014 putself                                                          (   1)
 <L000>
 0015 leave                                                            (   1)
---------------------
-e:1: argument stack underflow (-1)
Traceback (most recent call last):
-e: compile error (SyntaxError)
[1]    48279 exit 1     ./miniruby -ve 'begin raise ensure return end and self'
#3

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r59184.


fix return in toplevel ensure

  • compile.c (iseq_compile_each0): adjust stack after return in toplevel ensure, when the value is used. [ruby-core:81777] [Bug #13682]
#4

Updated by usa (Usaku NAKAMURA) over 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED
#5

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

Updated by nagachika (Tomoyuki Chikanaga) over 2 years ago

  • Backport changed from 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONE

ruby_2_4 r59493 merged revision(s) 59183,59184.

Also available in: Atom PDF