ruby-changes:32497
From: nagachika <ko1@a...>
Date: Sun, 12 Jan 2014 23:23:59 +0900 (JST)
Subject: [ruby-changes:32497] nagachika:r44576 (ruby_2_0_0): merge revision(s) 44260: [Backport #9168]
nagachika 2014-01-12 23:23:53 +0900 (Sun, 12 Jan 2014) New Revision: 44576 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44576 Log: merge revision(s) 44260: [Backport #9168] patch inspired from r44260 on trunk. [ruby-core:58652] [Bug #9168] * gc.c (run_finalizer): clear th->errinfo before invoke finalizer and restore afterward. * test/ruby/test_gc.rb (test_exception_in_finalizer): add test for above. * vm_trace.c (rb_threadptr_exec_event_hooks_orig): clear th->errinfo before invoke hook. Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/gc.c branches/ruby_2_0_0/test/ruby/test_gc.rb branches/ruby_2_0_0/version.h branches/ruby_2_0_0/vm_trace.c Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 44575) +++ ruby_2_0_0/ChangeLog (revision 44576) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Sun Jan 12 22:46:49 2014 CHIKANAGA Tomoyuki <nagachika@r...> + + patch inspired from r44260 on trunk. [ruby-core:58652] [Bug #9168] + + * gc.c (run_finalizer): clear th->errinfo before invoke finalizer and + restore afterward. + + * test/ruby/test_gc.rb (test_exception_in_finalizer): add test for + above. + + * vm_trace.c (rb_threadptr_exec_event_hooks_orig): clear th->errinfo + before invoke hook. + Sun Jan 12 16:07:52 2014 vo.x (Vit Ondruch) <vondruch@r...> * tool/rbinstall.rb (Gem::Specification#collect): make stable Index: ruby_2_0_0/gc.c =================================================================== --- ruby_2_0_0/gc.c (revision 44575) +++ ruby_2_0_0/gc.c (revision 44576) @@ -1375,6 +1375,7 @@ run_finalizer(rb_objspace_t *objspace, V https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L1375 int status; VALUE args[3]; VALUE objid = nonspecial_obj_id(obj); + VALUE saved_errinfo = rb_errinfo(); if (RARRAY_LEN(table) > 0) { args[1] = rb_obj_freeze(rb_ary_new3(1, objid)); @@ -1384,6 +1385,7 @@ run_finalizer(rb_objspace_t *objspace, V https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L1385 } args[2] = (VALUE)rb_safe_level(); + rb_set_errinfo(Qnil); for (i=0; i<RARRAY_LEN(table); i++) { VALUE final = RARRAY_PTR(table)[i]; args[0] = RARRAY_PTR(final)[1]; @@ -1393,6 +1395,7 @@ run_finalizer(rb_objspace_t *objspace, V https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L1395 if (status) rb_set_errinfo(Qnil); } + GET_THREAD()->errinfo = saved_errinfo; } static void Index: ruby_2_0_0/vm_trace.c =================================================================== --- ruby_2_0_0/vm_trace.c (revision 44575) +++ ruby_2_0_0/vm_trace.c (revision 44576) @@ -290,6 +290,7 @@ rb_threadptr_exec_event_hooks_orig(rb_tr https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_trace.c#L290 const int outer_state = th->state; int state = 0; th->state = 0; + th->errinfo = Qnil; th->vm->trace_running++; th->trace_arg = trace_arg; Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 44575) +++ ruby_2_0_0/version.h (revision 44576) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-01-12" -#define RUBY_PATCHLEVEL 383 +#define RUBY_PATCHLEVEL 384 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 Index: ruby_2_0_0/test/ruby/test_gc.rb =================================================================== --- ruby_2_0_0/test/ruby/test_gc.rb (revision 44575) +++ ruby_2_0_0/test/ruby/test_gc.rb (revision 44576) @@ -174,4 +174,17 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_gc.rb#L174 end; end end + + def test_exception_in_finalizer + bug9168 = '[ruby-core:58652] [Bug #9168]' + assert_normal_exit(<<-'end;', bug9168) + raise_proc = proc {raise} + 10000.times do + ObjectSpace.define_finalizer(Object.new, raise_proc) + Thread.handle_interrupt(RuntimeError => :immediate) {break} + Thread.handle_interrupt(RuntimeError => :on_blocking) {break} + Thread.handle_interrupt(RuntimeError => :never) {break} + end + end; + end end Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r44260 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/