Fix next inside block argument stack underflow
[Bug #20344] Fix compile_next adding removable adjust label
This commit is contained in:
parent
2a7da0b6e7
commit
992596fb7a
Notes:
git
2024-08-12 09:09:49 +00:00
@ -3070,8 +3070,7 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
|
|||||||
/* do nothing */
|
/* do nothing */
|
||||||
}
|
}
|
||||||
else if (IS_ADJUST(i)) {
|
else if (IS_ADJUST(i)) {
|
||||||
LABEL *dest = ((ADJUST *)i)->label;
|
return 0;
|
||||||
if (dest && dest->unremovable) return 0;
|
|
||||||
}
|
}
|
||||||
end = i;
|
end = i;
|
||||||
} while ((i = i->next) != 0);
|
} 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_ensure_iseq(ret, iseq, 0);
|
||||||
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
|
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
|
||||||
ADD_ADJUST_RESTORE(ret, splabel);
|
ADD_ADJUST_RESTORE(ret, splabel);
|
||||||
splabel->unremovable = FALSE;
|
|
||||||
|
|
||||||
if (!popped) {
|
if (!popped) {
|
||||||
ADD_INSN(ret, line_node, putnil);
|
ADD_INSN(ret, line_node, putnil);
|
||||||
|
@ -828,6 +828,27 @@ class TestISeq < Test::Unit::TestCase
|
|||||||
end;
|
end;
|
||||||
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
|
def test_loading_kwargs_memory_leak
|
||||||
assert_no_memory_leak([], "#{<<~"begin;"}", "#{<<~'end;'}", rss: true)
|
assert_no_memory_leak([], "#{<<~"begin;"}", "#{<<~'end;'}", rss: true)
|
||||||
a = RubyVM::InstructionSequence.compile("foo(bar: :baz)").to_binary
|
a = RubyVM::InstructionSequence.compile("foo(bar: :baz)").to_binary
|
||||||
|
Loading…
x
Reference in New Issue
Block a user