From 12102d101af258d7a3e9695b736a189cd3658df1 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 6 Sep 2023 14:20:23 -0400 Subject: Fix crash in WeakMap during compaction WeakMap can crash during compaction because the st_insert could allocate memory. --- test/ruby/test_weakmap.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb index b42787ad5e..a30004bce3 100644 --- a/test/ruby/test_weakmap.rb +++ b/test/ruby/test_weakmap.rb @@ -223,6 +223,18 @@ class TestWeakMap < Test::Unit::TestCase assert_equal(val, wm[key]) end; + + assert_separately(["-W0"], <<-'end;') + wm = ObjectSpace::WeakMap.new + + ary = 10_000.times.map do + o = Object.new + wm[o] = 1 + o + end + + GC.verify_compaction_references(expand_heap: true, toward: :empty) + end; end def test_replaced_values_bug_19531 -- cgit v1.2.3