diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-10 18:36:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-10 18:36:54 +0000 |
commit | 53861b8acd18cc5241d044f6246568cbac6a31cf (patch) | |
tree | 19a9e2139e2e72178b42f7b2887be8d216210ebc /test | |
parent | abd6dc8c10dc8dc8f19898cef507be2e13ed1d0e (diff) | |
download | ruby-53861b8acd18cc5241d044f6246568cbac6a31cf.tar.gz |
vm_trace.c: fix infinite hook
* thread.c (rb_threadptr_execute_interrupts): flush postponed job only
once at last.
* vm_trace.c (rb_postponed_job_flush): defer calling postponed jobs
registered while flushing to get rid of infinite reentrance of
ObjectSpace.after_gc_start_hook. [ruby-dev:47400] [Bug #8492]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/objspace/test_objspace.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 133b1e90a4..861e40e62b 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -172,4 +172,23 @@ class TestObjSpace < Test::Unit::TestCase assert_equal(nil, ObjectSpace.allocation_sourcefile(obj2)) assert_equal(nil, ObjectSpace.allocation_sourcefile(obj3)) end + + def test_after_gc_start_hook_with_GC_stress + bug8492 = '[ruby-dev:47400] [Bug #8492]: infinite after_gc_start_hook reentrance' + assert_nothing_raised(Timeout::Error, bug8492) do + assert_in_out_err(%w[-robjspace], <<-'end;', /\A[1-9]/, timeout: 2) + stress, GC.stress = GC.stress, false + count = 0 + ObjectSpace.after_gc_start_hook = proc {count += 1} + begin + GC.stress = true + 3.times {Object.new} + ensure + GC.stress = stress + ObjectSpace.after_gc_start_hook = nil + end + puts count + end; + end + end end |