diff --git a/vm.c b/vm.c index 1eefee18a6..54c5ed6c8d 100644 --- a/vm.c +++ b/vm.c @@ -1599,12 +1599,12 @@ vm_frametype_name(const rb_control_frame_t *cfp) #endif static void -hook_before_rewind(rb_thread_t *th, rb_control_frame_t *cfp, int will_finish_vm_exec) +hook_before_rewind(rb_thread_t *th, rb_control_frame_t *cfp, int will_finish_vm_exec, VALUE result) { switch (VM_FRAME_TYPE(th->cfp)) { case VM_FRAME_MAGIC_METHOD: RUBY_DTRACE_METHOD_RETURN_HOOK(th, 0, 0); - EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, 0, Qnil); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, 0, result); break; case VM_FRAME_MAGIC_BLOCK: case VM_FRAME_MAGIC_LAMBDA: @@ -1786,7 +1786,7 @@ vm_exec(rb_thread_t *th) if (!catch_iseq) { th->errinfo = Qnil; result = THROW_DATA_VAL(err); - hook_before_rewind(th, th->cfp, TRUE); + hook_before_rewind(th, th->cfp, TRUE, result); rb_vm_pop_frame(th); goto finish_vme; } @@ -1929,7 +1929,8 @@ vm_exec(rb_thread_t *th) } else { /* skip frame */ - hook_before_rewind(th, th->cfp, FALSE); + result = THROW_DATA_VAL(err); + hook_before_rewind(th, th->cfp, FALSE, result); if (VM_FRAME_FINISHED_P(th->cfp)) { rb_vm_pop_frame(th);