ruby-changes:47701
From: nagachika <ko1@a...>
Date: Sun, 10 Sep 2017 15:03:17 +0900 (JST)
Subject: [ruby-changes:47701] nagachika:r59817 (ruby_2_4): merge revision(s) 59649: [Backport #13832]
nagachika 2017-09-10 15:03:12 +0900 (Sun, 10 Sep 2017) New Revision: 59817 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59817 Log: merge revision(s) 59649: [Backport #13832] gc.c: restore cfp at finalizer * gc.c (run_finalizer): restore cfp for the case an exception raised in a finalizer. [ruby-core:82432] [Bug #13832] Modified files: branches/ruby_2_4/gc.c branches/ruby_2_4/test/ruby/test_gc.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 59816) +++ ruby_2_4/version.h (revision 59817) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-09-10" -#define RUBY_PATCHLEVEL 190 +#define RUBY_PATCHLEVEL 191 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 9 Index: ruby_2_4/gc.c =================================================================== --- ruby_2_4/gc.c (revision 59816) +++ ruby_2_4/gc.c (revision 59817) @@ -2734,12 +2734,14 @@ run_finalizer(rb_objspace_t *objspace, V https://github.com/ruby/ruby/blob/trunk/ruby_2_4/gc.c#L2734 } saved; rb_thread_t *const th = GET_THREAD(); #define RESTORE_FINALIZER() (\ + th->cfp = saved.cfp, \ rb_set_safe_level_force(saved.safe), \ rb_set_errinfo(saved.errinfo)) saved.safe = rb_safe_level(); saved.errinfo = rb_errinfo(); saved.objid = nonspecial_obj_id(obj); + saved.cfp = th->cfp; saved.finished = 0; TH_PUSH_TAG(th); Index: ruby_2_4/test/ruby/test_gc.rb =================================================================== --- ruby_2_4/test/ruby/test_gc.rb (revision 59816) +++ ruby_2_4/test/ruby/test_gc.rb (revision 59817) @@ -397,4 +397,27 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_gc.rb#L397 ObjectSpace.each_object{|o| case o when Module then o.instance_methods end} end end + + def test_exception_in_finalizer_method + @result = [] + def self.c1(x) + @result << :c1 + raise + end + def self.c2(x) + @result << :c2 + raise + end + tap { + tap { + obj = Object.new + ObjectSpace.define_finalizer(obj, method(:c1)) + ObjectSpace.define_finalizer(obj, method(:c2)) + obj = nil + } + } + GC.start + skip "finalizers did not get run" if @result.empty? + assert_equal([:c1, :c2], @result) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/