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.
This commit is contained in:
Jeremy Evans 2025-04-27 17:03:56 -07:00 committed by Jean Boussier
parent 3ec7bfff2e
commit 73f8d0a9c8

View File

@ -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