From 31e67a476f2262e01a0829e8ab5e6d8a97e0724e Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Fri, 14 Apr 2023 15:04:55 -0400 Subject: YJIT: Fix false object collection when setting ivar Previously, setinstancevariable could generate code that calls `rb_ensure_iv_list_size()` without first updating `cfp->sp`. This means in the event that a GC start from within said routine the top few objects would not be marked, causing them to be falsly collected. Call `jit_prepare_routine_call()` first. [Bug #19601] --- bootstraptest/test_yjit.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'bootstraptest') 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) -- cgit v1.2.1