[ruby-dev:48821] [ruby-trunk - Bug #10689] [Closed] `unexpected break' occurs when TracePoint#binding is called
From:
kazuki@...
Date:
2015-01-16 02:54:35 UTC
List:
ruby-dev #48821
Issue #10689 has been updated by Kazuki Tsujimoto.
Status changed from Open to Closed
% Done changed from 0 to 100
Applied in changeset r49266.
----------
* eval_intern.h, vm.c, vm_eval.c, vm_insnhelper.c:
change throw mechanism (not save target ep, but save target cfp).
It fixes `unexpected break' bug that occurs when
TracePoint#binding is called.
[ruby-dev:48797] [Bug #10689]
* test/ruby/test_settracefunc.rb: add a test.
----------------------------------------
Bug #10689: `unexpected break' occurs when TracePoint#binding is called
https://bugs.ruby-lang.org/issues/10689#change-51034
* Author: Kazuki Tsujimoto
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.0dev (2015-01-02 trunk 49102) [x86_64-linux]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED
----------------------------------------
以下のコードでunexpected breakになります。
~~~ruby
class Bug
include Enumerable
def each
[0].each do
yield
end
end
end
TracePoint.trace(:c_return) do |tp|
tp.binding
end
Bug.new.all? { false }
~~~
all?中のrb_iter_breakによってth->errinfoがセットされた後に、
TracePoint#binding呼び出しによってcfpのepがヒープを指すようになってしまうのが原因です。
とりあえずTracePoint呼び出し後にth->errinfoのepを書き換えるようにしてみたパッチを添付します。
---Files--------------------------------
fix-unexpected-break.patch (3.32 KB)
save-target-cfp-in-errinfo.patch (6.26 KB)
--
https://bugs.ruby-lang.org/