[Closed] TracePoint invoke unexpected b_call events with redo

Issue #9964 has been updated by Koichi Sasada.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r46471.


  • compile.c (rb_iseq_compile_node): put start label of block after
    trace (b_call).
    [Bug #9964]
  • test/ruby/test_settracefunc.rb: add a test.
    added assert_consistent_call_return() method check call/return
    consistency.

Bug #9964: TracePoint invoke unexpected b_call events with redo
https://bugs.ruby-lang.org/issues/9964#change-47306

  • Author: Koichi Sasada
  • Status: Closed
  • Priority: Normal
  • Assignee: Koichi Sasada
  • Category: core
  • Target version: current: 2.2.0
  • ruby -v: ruby 2.2
  • Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN

次のようなプログラムで、無限に b_call が発生し、対応する b_return が発生しません。

1.times{
  redo
}

これは、redo で b_call イベントを発生するところまで戻ってしまうためです。
redo した時、b_call イベントを発生する trace の へ戻るように変更することで解決できます。

Index: compile.c
===================================================================
--- compile.c  (revision 46468)
+++ compile.c  (working copy)
@@ -483,8 +483,8 @@
     LABEL *start = iseq->compile_data->start_label = NEW_LABEL(0);
     LABEL *end = iseq->compile_data->end_label = NEW_LABEL(0);

+    ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), 
RUBY_EVENT_B_CALL);
     ADD_LABEL(ret, start);
-    ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), 
RUBY_EVENT_B_CALL);
     COMPILE(ret, "block body", node->nd_body);
     ADD_LABEL(ret, end);
     ADD_TRACE(ret, nd_line(node), RUBY_EVENT_B_RETURN);

例によって 2.0 まで同じような問題があります。

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs