ruby-changes:51517
From: ktsj <ko1@a...>
Date: Sat, 23 Jun 2018 13:53:04 +0900 (JST)
Subject: [ruby-changes:51517] ktsj:r63727 (trunk): vm.c: fix infinite loop
ktsj 2018-06-23 13:52:58 +0900 (Sat, 23 Jun 2018) New Revision: 63727 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63727 Log: 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] Modified files: trunk/test/ruby/test_settracefunc.rb trunk/vm.c Index: vm.c =================================================================== --- vm.c (revision 63726) +++ vm.c (revision 63727) @@ -1846,10 +1846,10 @@ vm_exec_handle_exception(rb_execution_co https://github.com/ruby/ruby/blob/trunk/vm.c#L1846 while (ec->cfp->pc == 0 || ec->cfp->iseq == 0) { if (UNLIKELY(VM_FRAME_TYPE(ec->cfp) == VM_FRAME_MAGIC_CFUNC)) { - EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_RETURN, ec->cfp->self, - rb_vm_frame_method_entry(ec->cfp)->def->original_id, - rb_vm_frame_method_entry(ec->cfp)->called_id, - rb_vm_frame_method_entry(ec->cfp)->owner, Qnil); + EXEC_EVENT_HOOK_AND_POP_FRAME(ec, RUBY_EVENT_C_RETURN, ec->cfp->self, + rb_vm_frame_method_entry(ec->cfp)->def->original_id, + rb_vm_frame_method_entry(ec->cfp)->called_id, + rb_vm_frame_method_entry(ec->cfp)->owner, Qnil); RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, rb_vm_frame_method_entry(ec->cfp)->owner, rb_vm_frame_method_entry(ec->cfp)->def->original_id); Index: test/ruby/test_settracefunc.rb =================================================================== --- test/ruby/test_settracefunc.rb (revision 63726) +++ test/ruby/test_settracefunc.rb (revision 63727) @@ -896,6 +896,21 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L896 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{ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/