diff options
| author | tompng <tomoyapenguin@gmail.com> | 2024-08-06 23:29:45 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu.nakada@gmail.com> | 2024-08-12 18:09:32 +0900 |
| commit | 992596fb7af18a7f472589a607d0eb3fbb03b49a (patch) | |
| tree | 609d85d4553880bba35dba01bda5e792a5e9b0b9 | |
| parent | 2a7da0b6e76929c684cd948630a897c1d5b16c26 (diff) | |
Fix next inside block argument stack underflow
[Bug #20344]
Fix compile_next adding removable adjust label
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11316
| -rw-r--r-- | compile.c | 4 | ||||
| -rw-r--r-- | test/ruby/test_iseq.rb | 21 |
2 files changed, 22 insertions, 3 deletions
@@ -3070,8 +3070,7 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i) /* do nothing */ } else if (IS_ADJUST(i)) { - LABEL *dest = ((ADJUST *)i)->label; - if (dest && dest->unremovable) return 0; + return 0; } end = i; } while ((i = i->next) != 0); @@ -8205,7 +8204,6 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in add_ensure_iseq(ret, iseq, 0); ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label); ADD_ADJUST_RESTORE(ret, splabel); - splabel->unremovable = FALSE; if (!popped) { ADD_INSN(ret, line_node, putnil); diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 9429d8bc21..67d6606519 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -828,6 +828,27 @@ class TestISeq < Test::Unit::TestCase end; end + def test_unreachable_next_in_block + bug20344 = '[ruby-core:117210] [Bug #20344]' + assert_nothing_raised(SyntaxError, bug20344) do + compile(<<~RUBY) + proc do + next + + case nil + when "a" + next + when "b" + when "c" + proc {} + end + + next + end + RUBY + end + end + def test_loading_kwargs_memory_leak assert_no_memory_leak([], "#{<<~"begin;"}", "#{<<~'end;'}", rss: true) a = RubyVM::InstructionSequence.compile("foo(bar: :baz)").to_binary |
