Skip to content

Commit

Permalink
merge revision(s) 59956: [Backport #13705]
Browse files Browse the repository at this point in the history
	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_4@62651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nagachika committed Mar 4, 2018
1 parent fa0a9ea commit c2eabd8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
21 changes: 21 additions & 0 deletions test/ruby/test_settracefunc.rb
Expand Up @@ -1745,4 +1745,25 @@ def test_break_with_rescue
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
2 changes: 1 addition & 1 deletion version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.4"
#define RUBY_RELEASE_DATE "2018-03-04"
#define RUBY_PATCHLEVEL 248
#define RUBY_PATCHLEVEL 249

#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 3
Expand Down
3 changes: 2 additions & 1 deletion vm.c
Expand Up @@ -980,7 +980,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,
Expand All @@ -989,6 +989,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->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);
Expand Down

0 comments on commit c2eabd8

Please sign in to comment.