diff options
author | Peter Zhu <peter@peterzhu.ca> | 2023-09-06 14:20:23 -0400 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2023-09-06 14:20:23 -0400 |
commit | 12102d101af258d7a3e9695b736a189cd3658df1 (patch) | |
tree | 3182fb5048cb979df6b0d84c41e2469fe9fb6a57 /test | |
parent | 746eede412f083dc93923e39e3299c69fce46c15 (diff) |
Fix crash in WeakMap during compaction
WeakMap can crash during compaction because the st_insert could allocate
memory.
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_weakmap.rb | 12 |
1 files changed, 12 insertions, 0 deletions
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 |