mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e358e2f899
commit
39a6566426
4 changed files with 55 additions and 30 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu May 21 13:28:03 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* 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@tmtm.org>
|
||||
|
||||
* ext/socket/raddrinfo.c (addrinfo_mload): fix memory leak of
|
||||
|
|
|
@ -1348,4 +1348,24 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||
}
|
||||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#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
|
||||
|
|
56
vm.c
56
vm.c
|
@ -1285,6 +1285,30 @@ vm_frametype_name(const rb_control_frame_t *cfp)
|
|||
}
|
||||
#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_t *cfp)
|
|||
};
|
||||
*/
|
||||
|
||||
|
||||
static VALUE
|
||||
vm_exec(rb_thread_t *th)
|
||||
{
|
||||
|
@ -1451,15 +1474,9 @@ vm_exec(rb_thread_t *th)
|
|||
}
|
||||
}
|
||||
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)
|
|||
}
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue