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

gc.c: flush all deferred finalizers

* gc.c (finalize_deferred): flush all deferred finalizers while other
  finalizers can get ready to run newly by lazy sweep.
  [ruby-core:58833] [Bug #9205]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-05 01:47:12 +00:00
parent 3e36402e7f
commit c06f12031e
3 changed files with 22 additions and 3 deletions

View file

@ -1,3 +1,9 @@
Thu Dec 5 10:47:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (finalize_deferred): flush all deferred finalizers while other
finalizers can get ready to run newly by lazy sweep.
[ruby-core:58833] [Bug #9205]
Thu Dec 5 09:07:59 2013 Aman Gupta <ruby@tmm1.net>
* gc.c (ruby_gc_set_params): Accept safe_level argument so GC tuning

5
gc.c
View file

@ -2055,10 +2055,9 @@ finalize_list(rb_objspace_t *objspace, RVALUE *p)
static void
finalize_deferred(rb_objspace_t *objspace)
{
RVALUE *p = heap_pages_deferred_final;
heap_pages_deferred_final = 0;
RVALUE *p;
if (p) {
while ((p = ATOMIC_PTR_EXCHANGE(heap_pages_deferred_final, 0)) != 0) {
finalize_list(objspace, p);
}
}

View file

@ -238,4 +238,18 @@ class TestGc < Test::Unit::TestCase
assert_not_nil GC::INTERNAL_CONSTANTS[:HEAP_OBJ_LIMIT]
assert_not_nil GC::INTERNAL_CONSTANTS[:RVALUE_SIZE]
end
def test_sweep_in_finalizer
bug9205 = '[ruby-core:58833] [Bug #9205]'
100.times do
assert_ruby_status([], <<-'end;', bug9205)
raise_proc = proc do |id|
GC.start
end
1000.times do
ObjectSpace.define_finalizer(Object.new, raise_proc)
end
end;
end
end
end