From 150ed44d87e2d5b00f38019a487e05a67a303482 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 27 Nov 2023 11:30:47 -0500 Subject: Fix compaction during ary_make_partial The ary_make_shared call may allocate, which can trigger a GC compaction. This can cause the array to be embedded because it has a length of 0. --- test/ruby/test_array.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/ruby/test_array.rb') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 6c0db0832b..838ef15b91 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1693,6 +1693,10 @@ class TestArray < Test::Unit::TestCase assert_equal([100], a.slice(-1, 1_000_000_000)) end + def test_slice_gc_compact_stress + EnvUtil.under_gc_compact_stress { assert_equal([1, 2, 3, 4, 5], (0..10).to_a[1, 5]) } + end + def test_slice! a = @cls[1, 2, 3, 4, 5] assert_equal(3, a.slice!(2)) -- cgit v1.2.3