1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2013-10-10 18:36:54 +00:00
parent abd6dc8c10
commit 53861b8acd
4 changed files with 85 additions and 26 deletions

View file

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