summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_yjit.rb20
-rw-r--r--yjit/src/codegen.rs5
2 files changed, 25 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 99de63eafa..7cf39f2126 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1,3 +1,23 @@
+# Regression test for GC mishap while doing shape transition
+assert_equal '[:ok]', %q{
+ # [Bug #19601]
+ class RegressionTest
+ def initialize
+ @a = @b = @fourth_ivar_does_shape_transition = nil
+ end
+
+ def extender
+ @first_extended_ivar = [:ok]
+ end
+ end
+
+ GC.stress = true
+
+ # Used to crash due to GC run in rb_ensure_iv_list_size()
+ # not marking the newly allocated [:ok].
+ RegressionTest.new.extender.itself
+}
+
assert_equal 'true', %q{
# regression test for tracking type of locals for too long
def local_setting_cmp(five)
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index e135389ecf..e5437d707f 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -2290,6 +2290,11 @@ fn gen_setinstancevariable(
if needs_extension {
// Generate the C call so that runtime code will increase
// the capacity and set the buffer.
+ asm.comment("call rb_ensure_iv_list_size");
+
+ // It allocates so can trigger GC, which takes the VM lock
+ // so could yield to a different ractor.
+ jit_prepare_routine_call(jit, asm);
asm.spill_temps(); // for ccall
asm.ccall(rb_ensure_iv_list_size as *const u8,
vec![