summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-18 14:53:26 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-18 14:53:26 +0000
commit2fd7044e9a79df6b7f8248e8bae8d1850a211da1 (patch)
tree442d8f534ca22bdfc4bd344632627d17c30a0fa9
parentcc23dc6b239466817ec50c74c77264944180e1c8 (diff)
merge revision(s) 59956: [Backport #13705]
vm.c: fix `cfp consistency error' which occurs when raising exception in bmethod call event * vm.c (invoke_bmethod): set FINISH flag just before calling vm_exec. [ruby-dev:50162] [Bug #13705] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@62815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--test/ruby/test_settracefunc.rb21
-rw-r--r--version.h2
-rw-r--r--vm.c14
4 files changed, 38 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ed36db1086..bfd67f7362 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Mar 18 23:52:37 2018 Kazuki Tsujimoto <kazuki@callcc.net>
+
+ vm.c: fix `cfp consistency error' which occurs when raising exception
+ in bmethod call event
+
+ * vm.c (invoke_bmethod): set FINISH flag just before calling vm_exec.
+ [Bug #13705]
+
Sun Mar 18 23:36:24 2018 SHIBATA Hiroshi <hsbt@ruby-lang.org>
added workaround for APFS file format.
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 82fa2faaf9..cf11474ab5 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -1634,4 +1634,25 @@ class TestSetTraceFunc < Test::Unit::TestCase
tp_return_value(:f_break_in_rescue),
'[Bug #13369]'
end
+
+ def test_trace_point_raising_exception_in_bmethod_call
+ bug13705 = '[ruby-dev:50162]'
+ assert_normal_exit %q{
+ define_method(:m) {}
+
+ tp = TracePoint.new(:call) do
+ raise ''
+ end
+
+ tap do
+ tap do
+ begin
+ tp.enable
+ m
+ rescue
+ end
+ end
+ end
+ }, bug13705
+ end
end
diff --git a/version.h b/version.h
index 4a788ca4a9..232a5b499a 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.7"
#define RUBY_RELEASE_DATE "2018-03-18"
-#define RUBY_PATCHLEVEL 416
+#define RUBY_PATCHLEVEL 417
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 3
diff --git a/vm.c b/vm.c
index 89cd1c2f12..1e493ac2c3 100644
--- a/vm.c
+++ b/vm.c
@@ -928,15 +928,17 @@ invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const rb_bloc
int arg_size = iseq->body->param.size;
VALUE ret;
- vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_BMETHOD, self,
- VM_ENVVAL_PREV_EP_PTR(block->ep),
- (VALUE)me, /* cref or method (TODO: can we ignore cref?) */
- iseq->body->iseq_encoded + opt_pc,
- th->cfp->sp + arg_size, iseq->body->local_size - arg_size,
- iseq->body->stack_max);
+ rb_control_frame_t *cfp =
+ vm_push_frame(th, iseq, type | VM_FRAME_FLAG_BMETHOD, self,
+ VM_ENVVAL_PREV_EP_PTR(block->ep),
+ (VALUE)me, /* cref or method (TODO: can we ignore cref?) */
+ iseq->body->iseq_encoded + opt_pc,
+ th->cfp->sp + arg_size, iseq->body->local_size - arg_size,
+ iseq->body->stack_max);
RUBY_DTRACE_METHOD_ENTRY_HOOK(th, me->owner, me->def->original_id);
EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->def->original_id, me->owner, Qnil);
+ cfp->flag |= VM_FRAME_FLAG_FINISH;
ret = vm_exec(th);
EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->def->original_id, me->owner, ret);
RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->def->original_id);