summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-17 07:19:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-17 07:19:25 +0000
commita98e343d39c4d7bf1e2190b076720f32d9f298b3 (patch)
tree9501038d21dcc93d495c3c413695ecab7b4d5935
parent8859ff1d09d7d3787beacf2568d18d4208cdc356 (diff)
vm_trace.c: isolate exceptions
* vm_trace.c (rb_postponed_job_flush): isolate exceptions in postponed jobs and restore outer ones. based on a patch by tarui. [ruby-core:58652] [Bug #9168] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_gc.rb13
-rw-r--r--vm_trace.c3
3 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 1cfb424152..178eb702c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Dec 17 16:19:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm_trace.c (rb_postponed_job_flush): isolate exceptions in
+ postponed jobs and restore outer ones. based on a patch by
+ tarui. [ruby-core:58652] [Bug #9168]
+
Tue Dec 17 10:48:04 2013 Aman Gupta <ruby@tmm1.net>
* configure.in (RUBY_DTRACE_POSTPROCESS): Fix compatibility with
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index eb8d019679..1a7b38dbea 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -279,6 +279,19 @@ class TestGc < Test::Unit::TestCase
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
+
def test_verify_internal_consistency
assert_nil(GC.verify_internal_consistency)
end
diff --git a/vm_trace.c b/vm_trace.c
index 49a5fd0832..81452997e9 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -1511,7 +1511,9 @@ rb_postponed_job_flush(rb_vm_t *vm)
{
rb_thread_t *th = GET_THREAD();
unsigned long saved_postponed_job_interrupt_mask = th->interrupt_mask & POSTPONED_JOB_INTERRUPT_MASK;
+ VALUE saved_errno = th->errinfo;
+ th->errinfo = Qnil;
/* mask POSTPONED_JOB dispatch */
th->interrupt_mask |= POSTPONED_JOB_INTERRUPT_MASK;
{
@@ -1530,4 +1532,5 @@ rb_postponed_job_flush(rb_vm_t *vm)
}
/* restore POSTPONED_JOB mask */
th->interrupt_mask &= ~(saved_postponed_job_interrupt_mask ^ POSTPONED_JOB_INTERRUPT_MASK);
+ th->errinfo = saved_errno;
}