Issue #9205 has been updated by nobu (Nobuyoshi Nakada).


It doesn't seem nice to just ignore finalizers while running other finalizers.


diff --git c/gc.c i/gc.c index ddf607c..0d18031 100644 --- c/gc.c +++ i/gc.c @@ -2055,10 +2055,10 @@ 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 = heap_pages_deferred_final) != 0) { + heap_pages_deferred_final = 0; finalize_list(objspace, p); } } diff --git c/test/ruby/test_gc.rb i/test/ruby/test_gc.rb index 034a330..2b1e6a5 100644 --- c/test/ruby/test_gc.rb +++ i/test/ruby/test_gc.rb @@ -238,4 +238,19 @@ 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_raise_in_finalizer + bug9205 = '[ruby-core:58833] [Bug #9205]' + 100.times do + assert_ruby_status([], <<-'end;', bug9205) + STDOUT.sync = true + raise_proc = proc do |id| + p "Finalizer one on #{id}" + end + 10000.times do + ObjectSpace.define_finalizer(Object.new, raise_proc) + end + end; + end + end end ---------------------------------------- Bug #9205: Assertion failed: heap_pages_deferred_final == 0 https://bugs.ruby-lang.org/issues/9205#change-43408 Author: phasis68 (Heesob Park) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.1.0dev (2013-12-02 trunk 43958) [x64-mswin64_120] Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN If I run the following code: raise_proc = proc do |id| p "Finalizer one on #{id}" end 10000.times do ObjectSpace.define_finalizer(Object.new, raise_proc) end I can see an assertion failure. "Finalizer one on 24535120" Assertion failed: heap_pages_deferred_final == 0, file gc.c, line 2111 Same error with ruby 2.0.0p353 (2013-11-22) [i386-mingw32] -- http://bugs.ruby-lang.org/