merge revision(s) 59956: [Backport #13705]

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/branches/ruby_2_3@62815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2018-03-18 14:53:26 +00:00
parent cc23dc6b23
commit 2fd7044e9a
4 changed files with 38 additions and 7 deletions

View file

@ -1,3 +1,11 @@
Sun Mar 18 23:52:37 2018 Kazuki Tsujimoto <kazuki@callcc.net>
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.
[Bug #13705]
Sun Mar 18 23:36:24 2018 SHIBATA Hiroshi <hsbt@ruby-lang.org>
added workaround for APFS file format.

View file

@ -1634,4 +1634,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

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.7"
#define RUBY_RELEASE_DATE "2018-03-18"
#define RUBY_PATCHLEVEL 416
#define RUBY_PATCHLEVEL 417
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 3

14
vm.c
View file

@ -928,15 +928,17 @@ invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const rb_bloc
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_ENVVAL_PREV_EP_PTR(block->ep),
(VALUE)me, /* cref or method (TODO: can we ignore cref?) */
iseq->body->iseq_encoded + opt_pc,
th->cfp->sp + arg_size, iseq->body->local_size - arg_size,
iseq->body->stack_max);
rb_control_frame_t *cfp =
vm_push_frame(th, iseq, type | VM_FRAME_FLAG_BMETHOD, self,
VM_ENVVAL_PREV_EP_PTR(block->ep),
(VALUE)me, /* cref or method (TODO: can we ignore cref?) */
iseq->body->iseq_encoded + opt_pc,
th->cfp->sp + arg_size, iseq->body->local_size - arg_size,
iseq->body->stack_max);
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->owner, Qnil);
cfp->flag |= VM_FRAME_FLAG_FINISH;
ret = vm_exec(th);
EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->def->original_id, me->owner, ret);
RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->def->original_id);