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

ruby-changes:40560

From: usa <ko1@a...>
Date: Wed, 18 Nov 2015 20:18:01 +0900 (JST)
Subject: [ruby-changes:40560] usa:r52639 (ruby_2_1): merge revision(s) 51713: [Backport #11492] [Backport #11646]

usa	2015-11-18 20:17:54 +0900 (Wed, 18 Nov 2015)

  New Revision: 52639

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

  Log:
    merge revision(s) 51713: [Backport #11492] [Backport #11646]
    
    * vm.c (hook_before_rewind): prevent kicking :return event while
      finishing vm_exec func because invoke_block_from_c() kick a :return
      event for bmethods.
      [Bug #11492]
    
    * test/ruby/test_settracefunc.rb: add a test.

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/test/ruby/test_settracefunc.rb
    branches/ruby_2_1/version.h
    branches/ruby_2_1/vm.c
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 52638)
+++ ruby_2_1/ChangeLog	(revision 52639)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Wed Nov 18 20:14:38 2015  Koichi Sasada  <ko1@a...>
+
+	* vm.c (hook_before_rewind): prevent kicking :return event while
+	  finishing vm_exec func because invoke_block_from_c() kick a :return
+	  event for bmethods.
+	  [Bug #11492]
+
+	* test/ruby/test_settracefunc.rb: add a test.
+
 Wed Nov 18 20:10:31 2015  Aaron Patterson <tenderlove@r...>
 
 	* test/openssl/test_ssl_session.rb: Fix tests so that they take in to
Index: ruby_2_1/vm.c
===================================================================
--- ruby_2_1/vm.c	(revision 52638)
+++ ruby_2_1/vm.c	(revision 52639)
@@ -1286,7 +1286,7 @@ vm_frametype_name(const rb_control_frame https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L1286
 #endif
 
 static void
-hook_before_rewind(rb_thread_t *th, rb_control_frame_t *cfp)
+hook_before_rewind(rb_thread_t *th, rb_control_frame_t *cfp, int will_finish_vm_exec)
 {
     switch (VM_FRAME_TYPE(th->cfp)) {
       case VM_FRAME_MAGIC_METHOD:
@@ -1297,7 +1297,13 @@ hook_before_rewind(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L1297
       case VM_FRAME_MAGIC_LAMBDA:
 	if (VM_FRAME_TYPE_BMETHOD_P(th->cfp)) {
 	    EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
-	    EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, th->cfp->me->called_id, th->cfp->me->klass, Qnil);
+
+	    if (!will_finish_vm_exec) {
+		/* kick RUBY_EVENT_RETURN at invoke_block_from_c() for bmethod */
+		EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self,
+					      th->cfp->me->called_id,
+					      th->cfp->me->klass, Qnil);
+	    }
 	}
 	else {
 	    EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
@@ -1476,7 +1482,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L1482
 			if (!catch_iseqval) {
 			    th->errinfo = Qnil;
 			    result = GET_THROWOBJ_VAL(err);
-			    hook_before_rewind(th, th->cfp);
+			    hook_before_rewind(th, th->cfp, TRUE);
 			    vm_pop_frame(th);
 			    goto finish_vme;
 			}
@@ -1615,7 +1621,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L1621
 	}
 	else {
 	    /* skip frame */
-	    hook_before_rewind(th, th->cfp);
+	    hook_before_rewind(th, th->cfp, FALSE);
 
 	    if (VM_FRAME_TYPE_FINISH_P(th->cfp)) {
 		vm_pop_frame(th);
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 52638)
+++ ruby_2_1/version.h	(revision 52639)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.8"
 #define RUBY_RELEASE_DATE "2015-11-18"
-#define RUBY_PATCHLEVEL 414
+#define RUBY_PATCHLEVEL 415
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 11
Index: ruby_2_1/test/ruby/test_settracefunc.rb
===================================================================
--- ruby_2_1/test/ruby/test_settracefunc.rb	(revision 52638)
+++ ruby_2_1/test/ruby/test_settracefunc.rb	(revision 52639)
@@ -1184,6 +1184,74 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_settracefunc.rb#L1184
     end
   end
 
+  class C11492
+    define_method(:foo_return){
+      return true
+    }
+    define_method(:foo_break){
+      break true
+    }
+  end
+
+  def test_define_method_on_return
+    # return
+    events = []
+    obj = C11492.new
+    TracePoint.new(:call, :return){|tp|
+      next unless target_thread?
+      events << [tp.event, tp.method_id]
+    }.enable{
+      obj.foo_return
+    }
+    assert_equal([[:call, :foo_return], [:return, :foo_return]], events, 'Bug #11492')
+
+    # break
+    events = []
+    obj = C11492.new
+    TracePoint.new(:call, :return){|tp|
+      next unless target_thread?
+      events << [tp.event, tp.method_id]
+    }.enable{
+      obj.foo_break
+    }
+    assert_equal([[:call, :foo_break], [:return, :foo_break]], events, 'Bug #11492')
+
+    # set_trace_func
+    # return
+    events = []
+    begin
+      set_trace_func(lambda{|event, file, lineno, mid, binding, klass|
+        next unless target_thread?
+        case event
+        when 'call', 'return'
+          events << [event, mid]
+        end
+      })
+      obj.foo_return
+      set_trace_func(nil)
+
+      assert_equal([['call', :foo_return], ['return', :foo_return]], events, 'Bug #11492')
+    ensure
+    end
+
+    # break
+    events = []
+    begin
+      set_trace_func(lambda{|event, file, lineno, mid, binding, klass|
+        next unless target_thread?
+        case event
+        when 'call', 'return'
+          events << [event, mid]
+        end
+      })
+      obj.foo_break
+      set_trace_func(nil)
+
+      assert_equal([['call', :foo_break], ['return', :foo_break]], events, 'Bug #11492')
+    ensure
+    end
+  end
+
   def test_recursive
     assert_ruby_status [], %q{
       stack = []

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r51713


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

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