diff --git a/compile.c b/compile.c index c29d42e433..c62deafd23 100644 --- a/compile.c +++ b/compile.c @@ -1302,12 +1302,16 @@ static INSN * new_insn_send(rb_iseq_t *iseq, int line_no, ID id, VALUE argc, const rb_iseq_t *blockiseq, VALUE flag, struct rb_callinfo_kwarg *keywords) { VALUE *operands = compile_data_calloc2(iseq, sizeof(VALUE), 2); - operands[0] = (VALUE)new_callinfo(iseq, id, FIX2INT(argc), FIX2INT(flag), keywords, blockiseq != NULL); + VALUE ci = (VALUE)new_callinfo(iseq, id, FIX2INT(argc), FIX2INT(flag), keywords, blockiseq != NULL); + operands[0] = ci; operands[1] = (VALUE)blockiseq; if (blockiseq) { RB_OBJ_WRITTEN(iseq, Qundef, blockiseq); } - return new_insn_core(iseq, line_no, BIN(send), 2, operands); + INSN *insn = new_insn_core(iseq, line_no, BIN(send), 2, operands); + RB_OBJ_WRITTEN(iseq, Qundef, ci); + RB_GC_GUARD(ci); + return insn; } static rb_iseq_t * diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index daa8b5c37a..1f75a34cac 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -175,6 +175,16 @@ class TestGc < Test::Unit::TestCase assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) {GC.latest_gc_info(:"\u{30eb 30d3 30fc}")} end + def test_stress_compile_send + assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "") + GC.stress = true + begin + eval("A::B.c(1, 1, d: 234)") + rescue + end + EOS + end + def test_singleton_method assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "[ruby-dev:42832]") GC.stress = true diff --git a/version.h b/version.h index 4dd36f0766..237c19e138 100644 --- a/version.h +++ b/version.h @@ -12,7 +12,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 20 +#define RUBY_PATCHLEVEL 21 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 2