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

ruby-changes:34969

From: nagachika <ko1@a...>
Date: Mon, 4 Aug 2014 01:07:32 +0900 (JST)
Subject: [ruby-changes:34969] nagachika:r47051 (ruby_2_1): merge revision(s) r46465, r46469, r46484: [Backport #9961]

nagachika	2014-08-04 01:07:15 +0900 (Mon, 04 Aug 2014)

  New Revision: 47051

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

  Log:
    merge revision(s) r46465,r46469,r46484: [Backport #9961]
    
    * vm.c (rb_vm_rewind_cfp): add new function to rewind specified cfp
      with invoking RUBY_EVENT_C_RETURN.
      [Bug #9961]
    
    * vm_core.h: ditto.
    
    * eval.c (rb_protect): use it.
    
    * eval.c (rb_rescue2): ditto.
    
    * vm_eval.c (rb_iterate): ditto.
    
    * test/ruby/test_settracefunc.rb: add a test.
    
    * vm_core.h (rb_name_err_mesg_new): 
    
    * vm_eval.c (rb_catch_protect): fix same problem of [Bug #9961].
    
    * vm_eval.c (rb_iterate): ditto.
    
    * vm_core.h (rb_vm_rewind_cfp): add the prototype declaration.

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/eval.c
    branches/ruby_2_1/test/ruby/test_settracefunc.rb
    branches/ruby_2_1/version.h
    branches/ruby_2_1/vm.c
    branches/ruby_2_1/vm_core.h
    branches/ruby_2_1/vm_eval.c
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 47050)
+++ ruby_2_1/ChangeLog	(revision 47051)
@@ -1,3 +1,27 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Mon Aug  4 00:52:42 2014  Koichi Sasada  <ko1@a...>
+
+	* vm_eval.c (rb_catch_protect): fix same problem of [Bug #9961].
+
+	* vm_eval.c (rb_iterate): ditto.
+
+Mon Aug  4 00:52:42 2014  Koichi Sasada  <ko1@a...>
+
+	* vm.c (rb_vm_rewind_cfp): add new function to rewind specified cfp
+	  with invoking RUBY_EVENT_C_RETURN.
+	  [Bug #9961]
+
+	* vm_core.h: ditto.
+
+	* eval.c (rb_protect): use it.
+
+	* eval.c (rb_rescue2): ditto.
+
+	* vm_eval.c (rb_iterate): ditto.
+
+	* test/ruby/test_settracefunc.rb: add a test.
+
+	* vm_core.h (rb_vm_rewind_cfp): add the prototype declaration.
+
 Sun Aug  3 00:06:10 2014  Charlie Somerville  <charliesome@r...>
 
 	* node.c (dump_node): handle nd_value == (NODE *)-1 to mean this
Index: ruby_2_1/vm_core.h
===================================================================
--- ruby_2_1/vm_core.h	(revision 47050)
+++ ruby_2_1/vm_core.h	(revision 47051)
@@ -887,6 +887,7 @@ VALUE rb_name_err_mesg_new(VALUE obj, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_core.h#L887
 void rb_vm_stack_to_heap(rb_thread_t *th);
 void ruby_thread_init_stack(rb_thread_t *th);
 int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp);
+void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
 
 void rb_gc_mark_machine_stack(rb_thread_t *th);
 
Index: ruby_2_1/vm_eval.c
===================================================================
--- ruby_2_1/vm_eval.c	(revision 47050)
+++ ruby_2_1/vm_eval.c	(revision 47051)
@@ -1089,18 +1089,7 @@ rb_iterate(VALUE (* it_proc) (VALUE), VA https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_eval.c#L1089
 		th->errinfo = Qnil;
 		retval = GET_THROWOBJ_VAL(err);
 
-		/* check skipped frame */
-		while (th->cfp != cfp) {
-#if VMDEBUG
-		    printf("skipped frame: %s\n", vm_frametype_name(th->cfp));
-#endif
-		    if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_CFUNC) {
-			vm_pop_frame(th);
-		    }
-		    else { /* unlikely path */
-			rb_vm_pop_cfunc_frame();
-		    }
-		}
+		rb_vm_rewind_cfp(th, cfp);
 	    }
 	    else{
 		/* SDR(); printf("%p, %p\n", cdfp, escape_dfp); */
@@ -1111,10 +1100,11 @@ rb_iterate(VALUE (* it_proc) (VALUE), VA https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_eval.c#L1100
 	    VALUE *cep = cfp->ep;
 
 	    if (cep == escape_ep) {
+		rb_vm_rewind_cfp(th, cfp);
+
 		state = 0;
 		th->state = 0;
 		th->errinfo = Qnil;
-		th->cfp = cfp;
 		goto iter_retry;
 	    }
 	}
@@ -1858,7 +1848,7 @@ rb_catch_protect(VALUE t, rb_block_call_ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_eval.c#L1848
 	val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
     }
     else if (state == TAG_THROW && RNODE(th->errinfo)->u1.value == tag) {
-	th->cfp = saved_cfp;
+	rb_vm_rewind_cfp(th, saved_cfp);
 	val = th->tag->retval;
 	th->errinfo = Qnil;
 	state = 0;
Index: ruby_2_1/eval.c
===================================================================
--- ruby_2_1/eval.c	(revision 47050)
+++ ruby_2_1/eval.c	(revision 47051)
@@ -763,7 +763,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), V https://github.com/ruby/ruby/blob/trunk/ruby_2_1/eval.c#L763
 	}
     }
     else {
-	th->cfp = cfp; /* restore */
+	rb_vm_rewind_cfp(th, cfp);
 
 	if (state == TAG_RAISE) {
 	    int handle = FALSE;
@@ -822,7 +822,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_1/eval.c#L822
 	SAVE_ROOT_JMPBUF(th, result = (*proc) (data));
     }
     else {
-	th->cfp = cfp;
+	rb_vm_rewind_cfp(th, cfp);
     }
     MEMCPY(&(th)->root_jmpbuf, &org_jmpbuf, rb_jmpbuf_t, 1);
     th->protect_tag = protect_tag.prev;
Index: ruby_2_1/vm.c
===================================================================
--- ruby_2_1/vm.c	(revision 47050)
+++ ruby_2_1/vm.c	(revision 47051)
@@ -287,6 +287,23 @@ rb_vm_pop_cfunc_frame(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L287
     vm_pop_frame(th);
 }
 
+void
+rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
+{
+    /* check skipped frame */
+    while (th->cfp != cfp) {
+#if VMDEBUG
+	printf("skipped frame: %s\n", vm_frametype_name(th->cfp));
+#endif
+	if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_CFUNC) {
+	    vm_pop_frame(th);
+	}
+	else { /* unlikely path */
+	    rb_vm_pop_cfunc_frame();
+	}
+    }
+}
+
 /* obsolete */
 void
 rb_frame_pop(void)
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 47050)
+++ ruby_2_1/version.h	(revision 47051)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.2"
 #define RUBY_RELEASE_DATE "2014-08-04"
-#define RUBY_PATCHLEVEL 189
+#define RUBY_PATCHLEVEL 190
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_1/test/ruby/test_settracefunc.rb
===================================================================
--- ruby_2_1/test/ruby/test_settracefunc.rb	(revision 47050)
+++ ruby_2_1/test/ruby/test_settracefunc.rb	(revision 47051)
@@ -1290,6 +1290,55 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_settracefunc.rb#L1290
     assert_equal call_events, return_events.reverse, message
   end
 
+  def test_rb_rescue
+    events = []
+    curr_thread = Thread.current
+    TracePoint.new(:a_call, :a_return){|tp|
+      next if curr_thread != Thread.current
+      events << [tp.event, tp.method_id]
+    }.enable do
+      begin
+        -Numeric.new
+      rescue => e
+        # ignore
+      end
+    end
+
+    assert_equal [
+    [:b_call, :test_rb_rescue],
+      [:c_call, :new],
+        [:c_call, :initialize],
+        [:c_return, :initialize],
+      [:c_return, :new],
+      [:c_call, :-@],
+        [:c_call, :coerce],
+          [:c_call, :new],
+            [:c_call, :initialize],
+            [:c_return, :initialize],
+          [:c_return, :new],
+          [:c_call, :exception],
+          [:c_return, :exception],
+          [:c_call, :backtrace],
+          [:c_return, :backtrace],
+        [:c_return, :coerce],            # don't miss it!
+        [:c_call, :to_s],
+        [:c_return, :to_s],
+        [:c_call, :to_s],
+        [:c_return, :to_s],
+        [:c_call, :new],
+          [:c_call, :initialize],
+          [:c_return, :initialize],
+        [:c_return, :new],
+        [:c_call, :exception],
+        [:c_return, :exception],
+        [:c_call, :backtrace],
+        [:c_return, :backtrace],
+      [:c_return, :-@],
+      [:c_call, :===],
+      [:c_return, :===],
+    [:b_return, :test_rb_rescue]], events
+  end
+
   def test_b_call_with_redo
     assert_consistent_call_return do
       i = 0

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46465,46469,46484


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

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