[前][次][番号順一覧][スレッド一覧]

ruby-changes:26670

From: ko1 <ko1@a...>
Date: Mon, 7 Jan 2013 15:24:56 +0900 (JST)
Subject: [ruby-changes:26670] ko1:r38721 (trunk): * vm_trace.c (rb_threadptr_exec_event_hooks_orig): pop tag before

ko1	2013-01-07 15:24:46 +0900 (Mon, 07 Jan 2013)

  New Revision: 38721

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38721

  Log:
    * vm_trace.c (rb_threadptr_exec_event_hooks_orig): pop tag before
      JUMP_TAG() if frame is `finish' frame.
      Without this patch, there is an inconsistency between control
      frame stack and tags stack.
      [Bug #7668]
    * test/ruby/test_settracefunc.rb: add a test for above.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_settracefunc.rb
    trunk/vm_trace.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38720)
+++ ChangeLog	(revision 38721)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jan  7 15:24:10 2013  Koichi Sasada  <ko1@a...>
+
+	* vm_trace.c (rb_threadptr_exec_event_hooks_orig): pop tag before
+	  JUMP_TAG() if frame is `finish' frame.
+	  Without this patch, there is an inconsistency between control
+	  frame stack and tags stack.
+	  [Bug #7668]
+
+	* test/ruby/test_settracefunc.rb: add a test for above.
+
 Mon Jan  7 15:21:48 2013  NAKAMURA Usaku  <usa@r...>
 
 	* Makefile.in, common.mk (fake, yes-fake, no-make): these dependecies
Index: vm_trace.c
===================================================================
--- vm_trace.c	(revision 38720)
+++ vm_trace.c	(revision 38721)
@@ -316,7 +316,12 @@ rb_threadptr_exec_event_hooks_orig(rb_tr https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L316
 	th->vm->trace_running--;
 
 	if (state) {
-	    if (pop_p) th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
+	    if (pop_p) {
+		if (VM_FRAME_TYPE_FINISH_P(th->cfp)) {
+		    th->tag = th->tag->prev;
+		}
+		th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
+	    }
 	    TH_JUMP_TAG(th, state);
 	}
 	th->state = outer_state;
Index: test/ruby/test_settracefunc.rb
===================================================================
--- test/ruby/test_settracefunc.rb	(revision 38720)
+++ test/ruby/test_settracefunc.rb	(revision 38721)
@@ -870,5 +870,21 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L870
         m1_test_trace_point_at_return_when_exception
       end
     end
+
+    bug_7668 = '[Bug #7668]'
+    ary = []
+    trace = TracePoint.new{|tp|
+      ary << tp.event
+      raise
+    }
+    begin
+      trace.enable{
+        1.times{
+          raise
+        }
+      }
+    rescue
+      assert_equal([:b_call, :b_return], ary, bug_7668)
+    end
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]