From 73f8d0a9c8ff4bc3d9380a09ec8de2c6f100320c Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Sun, 27 Apr 2025 17:03:56 -0700 Subject: [PATCH] Fix nondeterministic failure in test_latest_gc_info_weak_references_count Clear the ary variable before setting it to nil. Otherwise, if the previous ary value was somewhere on the stack, all references in it would be considered live, and the wmap size would be 10000. --- test/ruby/test_gc.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index ccb46aeb9b..a1229fc87a 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -411,6 +411,8 @@ class TestGc < Test::Unit::TestCase before_weak_references_count = GC.latest_gc_info(:weak_references_count) before_retained_weak_references_count = GC.latest_gc_info(:retained_weak_references_count) + # Clear ary, so if ary itself is somewhere on the stack, it won't hold all references + ary.clear ary = nil # Free ary, which should empty out the wmap