1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 63727: [Backport #14865]

vm.c: fix infinite loop

	* vm.c: use EXEC_EVENT_HOOK_AND_POP_FRAME. While exception handling, if an exception
	  is raised in hooks, need to pop current frame and raise this raised exception by hook.

	[ruby-dev:50582] [Bug #14865]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@64129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2018-07-30 14:11:50 +00:00
parent 5b5739df1c
commit cd5c3d1265
3 changed files with 20 additions and 5 deletions

View file

@ -857,6 +857,21 @@ class TestSetTraceFunc < Test::Unit::TestCase
end
end
def test_tracepoint_exception_at_c_return
assert_nothing_raised(Timeout::Error, 'infinite trace') do
assert_normal_exit %q{
begin
TracePoint.new(:c_return){|tp|
raise
}.enable{
tap{ itself }
}
rescue
end
}, '', timeout: 3
end
end
def test_tracepoint_with_multithreads
assert_nothing_raised do
TracePoint.new{

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.5"
#define RUBY_RELEASE_DATE "2018-07-30"
#define RUBY_PATCHLEVEL 309
#define RUBY_PATCHLEVEL 310
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 7

8
vm.c
View file

@ -1797,10 +1797,10 @@ vm_exec(rb_thread_t *th)
while (th->cfp->pc == 0 || th->cfp->iseq == 0) {
if (UNLIKELY(VM_FRAME_TYPE(th->cfp) == VM_FRAME_MAGIC_CFUNC)) {
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, th->cfp->self,
rb_vm_frame_method_entry(th->cfp)->def->original_id,
rb_vm_frame_method_entry(th->cfp)->called_id,
rb_vm_frame_method_entry(th->cfp)->owner, Qnil);
EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_C_RETURN, th->cfp->self,
rb_vm_frame_method_entry(th->cfp)->def->original_id,
rb_vm_frame_method_entry(th->cfp)->called_id,
rb_vm_frame_method_entry(th->cfp)->owner, Qnil);
RUBY_DTRACE_CMETHOD_RETURN_HOOK(th,
rb_vm_frame_method_entry(th->cfp)->owner,
rb_vm_frame_method_entry(th->cfp)->def->original_id);