diff options
author | nari <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 22:56:02 +0000 |
---|---|---|
committer | nari <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 22:56:02 +0000 |
commit | 59770bf960aba2ef14cb5306606bbb6a64d38188 (patch) | |
tree | 580330be3d453f2a7a2fb4ef03557b738f2ff5dd | |
parent | c86379402c8dfeab9504c39c2de435601d408e57 (diff) | |
download | ruby-59770bf960aba2ef14cb5306606bbb6a64d38188.tar.gz |
* gc.c (rb_objspace_call_finalizer): finalize_deferred may free up
a object which is reachable from a part after this function,
e.g. ruby_vm_destruct(). [ruby-dev:46647] [Bug #7452]
* test/ruby/test_gc.rb (test_finalizing_main_thread): add a test
for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | gc.c | 12 | ||||
-rw-r--r-- | test/ruby/test_gc.rb | 6 |
3 files changed, 19 insertions, 10 deletions
@@ -1,3 +1,12 @@ +Fri Nov 30 07:46:42 2012 Narihiro Nakamura <authornari@gmail.com> + + * gc.c (rb_objspace_call_finalizer): finalize_deferred may free up + a object which is reachable from a part after this function, + e.g. ruby_vm_destruct(). [ruby-dev:46647] [Bug #7452] + + * test/ruby/test_gc.rb (test_finalizing_main_thread): add a test + for above. + Fri Nov 30 07:43:44 2012 Koichi Sasada <ko1@atdot.net> * thread.c (rb_thread_interrupted): avoid warning of @@ -462,7 +471,7 @@ Wed Nov 28 16:41:04 2012 Eric Hodel <drbrain@segment7.net> * lib/rdoc/servlet.rb: Add support for serving documentation from a subdirectory. * lib/rdoc/generator/darkfish.rb: ditto - * test/rdoc/test_rdoc_servlet.rb: Test for above + * test/rdoc/test_rdoc_servlet.rb: Tets for above * test/rdoc/test_rdoc_servlet.rb: ditto Wed Nov 28 15:37:17 2012 NARUSE, Yui <naruse@ruby-lang.org> @@ -1504,15 +1504,9 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace) if (ATOMIC_EXCHANGE(finalizing, 1)) return; /* run finalizers */ - do { - finalize_deferred(objspace); - /* mark reachable objects from finalizers */ - /* They might be not referred from any place here */ - mark_tbl(objspace, finalizer_table); - gc_mark_stacked_objects(objspace); - st_foreach(finalizer_table, chain_finalized_object, - (st_data_t)&deferred_final_list); - } while (deferred_final_list); + finalize_deferred(objspace); + assert(deferred_final_list == 0); + /* force to run finalizer */ while (finalizer_table->num_entries) { struct force_finalize_list *list = 0; diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 9d68c1a9c0..11d2b4c596 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -134,4 +134,10 @@ class TestGc < Test::Unit::TestCase ensure GC::Profiler.disable end + + def test_finalizing_main_thread + assert_in_out_err(%w[--disable-gems], <<-EOS, ["\"finalize\""], [], "[ruby-dev:46647]") + ObjectSpace.define_finalizer(Thread.main) { p 'finalize' } + EOS + end end |