vm.c: pass exceptions while handling an exception

* vm.c (vm_exec): pass exceptions while handling an exception.
* vm_trace.c (rb_threadptr_exec_event_hooks): propagate exceptions.
  revert r38293 partially.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-12-11 18:45:43 +00:00
parent 8dafe8c88d
commit 63d0ea4c03
4 changed files with 15 additions and 3 deletions

View File

@ -1,3 +1,10 @@
Wed Dec 12 03:45:41 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm.c (vm_exec): pass exceptions while handling an exception.
* vm_trace.c (rb_threadptr_exec_event_hooks): propagate exceptions.
revert r38293 partially.
Wed Dec 12 03:09:05 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Dec 12 03:09:05 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sample/test.rb (Progress#initialize): add --verbose option and show * sample/test.rb (Progress#initialize): add --verbose option and show

View File

@ -801,7 +801,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
end end
def test_tracepoint_exception_at_line def test_tracepoint_exception_at_line
assert_nothing_raised do assert_raise(RuntimeError) do
TracePoint.new(:line) {raise}.enable { TracePoint.new(:line) {raise}.enable {
1 1
} }

3
vm.c
View File

@ -1162,6 +1162,7 @@ vm_exec(rb_thread_t *th)
_tag.retval = Qnil; _tag.retval = Qnil;
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
vm_loop_start: vm_loop_start:
_th->tag = &_tag;
result = vm_exec_core(th, initial); result = vm_exec_core(th, initial);
if ((state = th->state) != 0) { if ((state = th->state) != 0) {
err = result; err = result;
@ -1180,6 +1181,7 @@ vm_exec(rb_thread_t *th)
err = th->errinfo; err = th->errinfo;
exception_handler: exception_handler:
TH_POP_TAG2();
cont_pc = cont_sp = catch_iseqval = 0; cont_pc = cont_sp = catch_iseqval = 0;
while (th->cfp->pc == 0 || th->cfp->iseq == 0) { while (th->cfp->pc == 0 || th->cfp->iseq == 0) {
@ -1373,7 +1375,6 @@ vm_exec(rb_thread_t *th)
if (VM_FRAME_TYPE_FINISH_P(th->cfp)) { if (VM_FRAME_TYPE_FINISH_P(th->cfp)) {
vm_pop_frame(th); vm_pop_frame(th);
th->errinfo = err; th->errinfo = err;
TH_POP_TAG2();
JUMP_TAG(state); JUMP_TAG(state);
} }
else { else {

View File

@ -309,11 +309,15 @@ rb_threadptr_exec_event_hooks(rb_trace_arg_t *targ)
state = exec_hooks(th, list, targ, !vm_tracing); state = exec_hooks(th, list, targ, !vm_tracing);
if (state) goto terminate; if (state) goto terminate;
} }
th->errinfo = errinfo;
} }
terminate: terminate:
th->errinfo = errinfo;
th->trace_running = 0; th->trace_running = 0;
th->vm->trace_running = vm_tracing; th->vm->trace_running = vm_tracing;
if (state) {
TH_JUMP_TAG(th, state);
}
th->state = outer_state; th->state = outer_state;
} }
} }