summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--test/ruby/test_settracefunc.rb20
-rw-r--r--version.h2
-rw-r--r--vm.c56
4 files changed, 55 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 382c046a08..6f1aa702e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun May 24 02:44:53 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.
+
Sun May 24 02:21:47 2015 Masahiro Tomita <tommy@tmtm.org>
* ext/socket/raddrinfo.c (addrinfo_mload): fix memory leak of
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 58e927c217..1dcd2ccbee 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -1332,4 +1332,24 @@ class TestSetTraceFunc < Test::Unit::TestCase
}
assert_equal [__LINE__ - 3, __LINE__ - 2], lines, 'Bug #10449'
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
diff --git a/version.h b/version.h
index fc0de05a50..171000328e 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.3"
#define RUBY_RELEASE_DATE "2015-05-24"
-#define RUBY_PATCHLEVEL 120
+#define RUBY_PATCHLEVEL 121
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 5
diff --git a/vm.c b/vm.c
index e0b536d195..17f3c53ef5 100644
--- a/vm.c
+++ b/vm.c
@@ -1287,6 +1287,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
@@ -1385,7 +1409,6 @@ vm_frametype_name(const rb_control_frame_t *cfp)
};
*/
-
static VALUE
vm_exec(rb_thread_t *th)
{
@@ -1455,15 +1478,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;
}
@@ -1606,26 +1623,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);