diff options
author | ktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-18 08:21:08 +0000 |
---|---|---|
committer | ktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-18 08:21:08 +0000 |
commit | 698f2db2240c81a21b9cad56d46fbc1ea02c7042 (patch) | |
tree | 989fa98378a43cb12c4ce3a75466645e72189488 | |
parent | 13f5dcb9f25cf07ef22baa5aded490395700b283 (diff) | |
download | ruby-698f2db2240c81a21b9cad56d46fbc1ea02c7042.tar.gz |
vm.c: fix `cfp consistency error' which occurs
when raising exception in bmethod call event
* vm.c (invoke_bmethod): set FINISH flag just before calling vm_exec.
[ruby-dev:50162] [Bug #13705]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_settracefunc.rb | 21 | ||||
-rw-r--r-- | vm.c | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 2b32a155d5..c274a25cac 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1741,4 +1741,25 @@ class TestSetTraceFunc < Test::Unit::TestCase tp_return_value(:f_break_in_rescue), '[Bug #13369]' end + + def test_trace_point_raising_exception_in_bmethod_call + bug13705 = '[ruby-dev:50162]' + assert_normal_exit %q{ + define_method(:m) {} + + tp = TracePoint.new(:call) do + raise '' + end + + tap do + tap do + begin + tp.enable + m + rescue + end + end + end + }, bug13705 + end end @@ -990,7 +990,7 @@ invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const struct int arg_size = iseq->body->param.size; VALUE ret; - vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_BMETHOD, self, + vm_push_frame(th, iseq, type | VM_FRAME_FLAG_BMETHOD, self, VM_GUARDED_PREV_EP(captured->ep), (VALUE)me, iseq->body->iseq_encoded + opt_pc, @@ -1000,6 +1000,7 @@ invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const struct RUBY_DTRACE_METHOD_ENTRY_HOOK(th, me->owner, me->def->original_id); EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->def->original_id, me->called_id, me->owner, Qnil); + VM_ENV_FLAGS_SET(th->ec.cfp->ep, VM_FRAME_FLAG_FINISH); ret = vm_exec(th); EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->def->original_id, me->called_id, me->owner, ret); RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->def->original_id); |