Forum: Ruby-dev [ruby-trunk - Bug #10689] `unexpected break' occurs when TracePoint#binding is called

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
308cbef6e86dfc49cce3b2d4cf42aedc?d=identicon&s=25 unknown (Guest)
on 2015-01-08 20:32
(Received via mailing list)
Issue #10689 has been updated by Koichi Sasada.


ありがとうございます!

頂いたパッチを元に、cfp を使うように整理してみました。
http://www.atdot.net/sp/view/e5ivhn

* vm_throw() を簡素化
* マクロっぽい名前を関数っぽく

一応、test-all/test-rubyspec は通っていますが、良さそうでしたらコミットしてもらえないでしょうか。


----------------------------------------
Bug #10689: `unexpected break' occurs when TracePoint#binding is called
https://bugs.ruby-lang.org/issues/10689#change-50865

* Author: Kazuki Tsujimoto
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version:
* 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)
This topic is locked and can not be replied to.