From c2693f8bd61757e32d2f92010c041a79b21d074a Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 25 Dec 2012 13:24:17 +0000 Subject: * vm_trace.c (rb_threadptr_exec_event_hooks_and_pop_frame): pop a frame before JUMP_TAG() if exception occurred. This change fix bug of Ruby 1.9. [ruby-core:51128] [ruby-trunk - Bug #7624] * vm_core.h (EXEC_EVENT_HOOK_AND_POP_FRAME): add to use `rb_threadptr_exec_event_hooks_and_pop_frame()'. * vm.c (vm_exec): use EXEC_EVENT_HOOK_AND_POP_FRAME() while exception handling. While exception hadnling, if an exception is raised in hooks, need to pop current frame and raise this raised exception by hook. * test/ruby/test_settracefunc.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 9ed5d08fa2..a05f3690f5 100644 --- a/vm.c +++ b/vm.c @@ -1160,7 +1160,6 @@ vm_exec(rb_thread_t *th) _tag.retval = Qnil; if ((state = EXEC_TAG()) == 0) { vm_loop_start: - _th->tag = &_tag; result = vm_exec_core(th, initial); if ((state = th->state) != 0) { err = result; @@ -1179,7 +1178,6 @@ vm_exec(rb_thread_t *th) err = th->errinfo; exception_handler: - TH_POP_TAG2(); cont_pc = cont_sp = catch_iseqval = 0; while (th->cfp->pc == 0 || th->cfp->iseq == 0) { @@ -1360,19 +1358,20 @@ vm_exec(rb_thread_t *th) switch (VM_FRAME_TYPE(th->cfp)) { case VM_FRAME_MAGIC_METHOD: RUBY_DTRACE_METHOD_RETURN_HOOK(th, 0, 0); - EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, Qnil); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, Qnil); break; case VM_FRAME_MAGIC_BLOCK: - EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); break; case VM_FRAME_MAGIC_CLASS: - EXEC_EVENT_HOOK(th, RUBY_EVENT_END, th->cfp->self, 0, 0, Qnil); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0, Qnil); break; } if (VM_FRAME_TYPE_FINISH_P(th->cfp)) { vm_pop_frame(th); th->errinfo = err; + TH_POP_TAG2(); JUMP_TAG(state); } else { -- cgit v1.2.3