From 0f711026e2da7ebcd8933c987d8b0a835f1ae153 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 23 Aug 2017 02:26:02 +0000 Subject: gc.c: run all finalizers * gc.c (run_finalizer): revert r59155 partially. finalizing loop should continue even after an exception is rescued. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_gc.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/ruby/test_gc.rb') diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index a5fd2897a2..2e26fde5c1 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -397,4 +397,26 @@ class TestGc < Test::Unit::TestCase ObjectSpace.each_object{|o| case o when Module then o.instance_methods end} end end + + def test_exception_in_finalizer + result = [] + c1 = proc do + result << :c1 + raise + end + c2 = proc do + result << :c2 + raise + end + tap { + tap { + obj = Object.new + ObjectSpace.define_finalizer(obj, c1) + ObjectSpace.define_finalizer(obj, c2) + obj = nil + } + } + GC.start + assert_equal([:c1, :c2], result) + end end -- cgit v1.2.1