diff options
author | Peter Zhu <[email protected]> | 2023-12-18 20:55:59 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-12-21 10:39:03 -0500 |
commit | e191bf42d2077a025c21888573f8b81688e5ea28 (patch) | |
tree | 69e009c2b48a2da585672c04b6dfc59b864ef377 /test/ruby/test_array.rb | |
parent | fd4735130e5fdc0a11f970092d5900847a3ce4cf (diff) |
Fix ary_make_partial_step for compaction
ary could change embeddedness due to compaction, so we should only get
the pointer after allocations.
The included test was crashing with:
TestArray#test_slice_gc_compact_stress
ruby/lib/pp.rb:192: [BUG] Segmentation fault at 0x0000000000000038
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 558e1c2042..97e2fa3de8 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1704,6 +1704,10 @@ class TestArray < Test::Unit::TestCase def test_slice_gc_compact_stress EnvUtil.under_gc_compact_stress { assert_equal([1, 2, 3, 4, 5], (0..10).to_a[1, 5]) } + EnvUtil.under_gc_compact_stress do + a = [0, 1, 2, 3, 4, 5] + assert_equal([2, 1, 0], a.slice((2..).step(-1))) + end end def test_slice! |