summaryrefslogtreecommitdiff
path: root/test/ruby/test_weakmap.rb
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-09-06 14:20:23 -0400
committerPeter Zhu <peter@peterzhu.ca>2023-09-06 14:20:23 -0400
commit12102d101af258d7a3e9695b736a189cd3658df1 (patch)
tree3182fb5048cb979df6b0d84c41e2469fe9fb6a57 /test/ruby/test_weakmap.rb
parent746eede412f083dc93923e39e3299c69fce46c15 (diff)
Fix crash in WeakMap during compaction
WeakMap can crash during compaction because the st_insert could allocate memory.
Diffstat (limited to 'test/ruby/test_weakmap.rb')
-rw-r--r--test/ruby/test_weakmap.rb12
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