From ff9dc109665e515da8b544a55085bb793063adf1 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 17 Sep 2020 09:43:32 -0700 Subject: keep proc on the stack so it does not move --- test/-ext-/tracepoint/test_tracepoint.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'test/-ext-') diff --git a/test/-ext-/tracepoint/test_tracepoint.rb b/test/-ext-/tracepoint/test_tracepoint.rb index 79ba090e4c..9d1679602a 100644 --- a/test/-ext-/tracepoint/test_tracepoint.rb +++ b/test/-ext-/tracepoint/test_tracepoint.rb @@ -62,9 +62,11 @@ class TestTracepointObj < Test::Unit::TestCase bug8492 = '[ruby-dev:47400] [Bug #8492]: infinite after_gc_start_hook reentrance' assert_nothing_raised(Timeout::Error, bug8492) do assert_in_out_err(%w[-r-test-/tracepoint], <<-'end;', /\A[1-9]/, timeout: 2) - stress, GC.stress = GC.stress, false count = 0 - Bug.after_gc_start_hook = proc {count += 1} + hook = proc {count += 1} + def run(hook) + stress, GC.stress = GC.stress, false + Bug.after_gc_start_hook = hook begin GC.stress = true 3.times {Object.new} @@ -72,6 +74,8 @@ class TestTracepointObj < Test::Unit::TestCase GC.stress = stress Bug.after_gc_start_hook = nil end + end + run(hook) puts count end; end -- cgit v1.2.3