ruby-changes:38495
From: usa <ko1@a...>
Date: Thu, 21 May 2015 13:31:35 +0900 (JST)
Subject: [ruby-changes:38495] usa:r50576 (ruby_2_1): merge revision(s) 50206: [Backport #10724]
usa 2015-05-21 13:31:19 +0900 (Thu, 21 May 2015) New Revision: 50576 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50576 Log: merge revision(s) 50206: [Backport #10724] * vm.c (vm_exec): check other events when RETURN is thrown. [Bug #10724] * test/ruby/test_settracefunc.rb: add a test. Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/test/ruby/test_settracefunc.rb branches/ruby_2_1/version.h branches/ruby_2_1/vm.c Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 50575) +++ ruby_2_1/ChangeLog (revision 50576) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Thu May 21 13:28:03 2015 Koichi Sasada <ko1@a...> + + * vm.c (vm_exec): check other events when RETURN is thrown. + [Bug #10724] + + * test/ruby/test_settracefunc.rb: add a test. + Thu May 21 13:23:44 2015 Masahiro Tomita <tommy@t...> * ext/socket/raddrinfo.c (addrinfo_mload): fix memory leak of Index: ruby_2_1/vm.c =================================================================== --- ruby_2_1/vm.c (revision 50575) +++ ruby_2_1/vm.c (revision 50576) @@ -1285,6 +1285,30 @@ vm_frametype_name(const rb_control_frame https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L1285 } #endif +static void +hook_before_rewind(rb_thread_t *th, rb_control_frame_t *cfp) +{ + switch (VM_FRAME_TYPE(th->cfp)) { + case VM_FRAME_MAGIC_METHOD: + RUBY_DTRACE_METHOD_RETURN_HOOK(th, 0, 0); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, Qnil); + break; + case VM_FRAME_MAGIC_BLOCK: + case VM_FRAME_MAGIC_LAMBDA: + if (VM_FRAME_TYPE_BMETHOD_P(th->cfp)) { + EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, th->cfp->me->called_id, th->cfp->me->klass, Qnil); + } + else { + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); + } + break; + case VM_FRAME_MAGIC_CLASS: + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0, Qnil); + break; + } +} + /* evaluator body */ /* finish @@ -1383,7 +1407,6 @@ vm_frametype_name(const rb_control_frame https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L1407 }; */ - static VALUE vm_exec(rb_thread_t *th) { @@ -1451,15 +1474,9 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L1474 } } if (!catch_iseqval) { - result = GET_THROWOBJ_VAL(err); th->errinfo = Qnil; - - switch (VM_FRAME_TYPE(cfp)) { - case VM_FRAME_MAGIC_LAMBDA: - EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); - break; - } - + result = GET_THROWOBJ_VAL(err); + hook_before_rewind(th, th->cfp); vm_pop_frame(th); goto finish_vme; } @@ -1598,26 +1615,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L1615 } else { /* skip frame */ - - switch (VM_FRAME_TYPE(th->cfp)) { - case VM_FRAME_MAGIC_METHOD: - RUBY_DTRACE_METHOD_RETURN_HOOK(th, 0, 0); - EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, Qnil); - break; - case VM_FRAME_MAGIC_BLOCK: - case VM_FRAME_MAGIC_LAMBDA: - if (VM_FRAME_TYPE_BMETHOD_P(th->cfp)) { - EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); - EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, th->cfp->me->called_id, th->cfp->me->klass, Qnil); - } - else { - EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); - } - break; - case VM_FRAME_MAGIC_CLASS: - EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0, Qnil); - break; - } + hook_before_rewind(th, th->cfp); if (VM_FRAME_TYPE_FINISH_P(th->cfp)) { vm_pop_frame(th); Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 50575) +++ ruby_2_1/version.h (revision 50576) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.7" #define RUBY_RELEASE_DATE "2015-05-21" -#define RUBY_PATCHLEVEL 349 +#define RUBY_PATCHLEVEL 350 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 5 Index: ruby_2_1/test/ruby/test_settracefunc.rb =================================================================== --- ruby_2_1/test/ruby/test_settracefunc.rb (revision 50575) +++ ruby_2_1/test/ruby/test_settracefunc.rb (revision 50576) @@ -1348,4 +1348,24 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_settracefunc.rb#L1348 } end end + + class Bug10724 + def initialize + loop{return} + end + end + + def test_throwing_return_with_finish_frame + target_th = Thread.current + evs = [] + + TracePoint.new(:call, :return){|tp| + return if Thread.current != target_th + evs << tp.event + }.enable{ + a = Bug10724.new + } + + assert_equal([:call, :return], evs) + end end Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r50206 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/