From: nagachika00@gmail•com
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50490] [Ruby trunk Bug#13705] [PATCH] `cfp consistency error' occurs when raising exception in bmethod call event
Date: Sun, 04 Mar 2018 02:18:04 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-70769.20180304021802.0d0e139d527f09c3@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13705.20170702023412@ruby-lang.org
Issue #13705 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 2.2: WONTFIX, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: WONTFIX, 2.3: REQUIRED, 2.4: DONE
ruby_2_4 r62651 merged revision(s) 59956.
----------------------------------------
Bug #13705: [PATCH] `cfp consistency error' occurs when raising exception in bmethod call event
https://bugs.ruby-lang.org/issues/13705#change-70769
* Author: ktsj (Kazuki Tsujimoto)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0dev (2017-07-02 master 59246) [x86_64-linux]
* Backport: 2.2: WONTFIX, 2.3: REQUIRED, 2.4: DONE
----------------------------------------
bmethodのcallイベントの中でキャッチされない例外を起こすとcfp consistency errorになります。
~~~ruby
define_method(:m) {}
tp = TracePoint.new(:call) do
raise ''
end
tap do
tap do
begin
tp.enable
m
rescue
end
end
end
~~~
invoke_bmethodでFINISHフラグが立ったフレームを積んでからvm_execを呼び出すまでの間に
EXEC_EVENT_HOOKを呼んでいるのが原因です。
EXEC_EVENT_HOOKの呼び出し後にフレームを積むよう修正すると互換性に影響するので
FINISHフラグの設定をvm_execの直前に遅延させるのがよさそうです。
~~~diff
diff --git a/vm.c b/vm.c
index 6ff1d23..d0c11c8 100644
--- a/vm.c
+++ b/vm.c
@@ -986,7 +986,7 @@ invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const struct
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_push_frame(th, iseq, type | VM_FRAME_FLAG_BMETHOD, self,
VM_GUARDED_PREV_EP(captured->ep),
(VALUE)me,
iseq->body->iseq_encoded + opt_pc,
@@ -996,6 +996,7 @@ invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const struct
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->called_id, me->owner, Qnil);
+ VM_ENV_FLAGS_SET(th->ec.cfp->ep, VM_FRAME_FLAG_FINISH);
ret = vm_exec(th);
EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->def->original_id, me->called_id, me->owner, ret);
RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
~~~
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2018-03-04 2:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-13705.20170702023412@ruby-lang.org>
2017-07-02 2:34 ` [ruby-dev:50162] [Ruby trunk Bug#13705] [PATCH] `cfp consistency error' occurs when raising exception in bmethod call event kazuki
2018-03-04 2:18 ` nagachika00 [this message]
2018-03-18 14:53 ` [ruby-dev:50505] " usa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-70769.20180304021802.0d0e139d527f09c3@ruby-lang.org \
--to=ruby-dev@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).