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

ruby-changes:45955

From: nagachika <ko1@a...>
Date: Mon, 20 Mar 2017 06:08:01 +0900 (JST)
Subject: [ruby-changes:45955] nagachika:r58026 (ruby_2_3): merge revision(s) 56125, 56150: [Backport #12741]

nagachika	2017-03-20 06:07:54 +0900 (Mon, 20 Mar 2017)

  New Revision: 58026

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

  Log:
    merge revision(s) 56125,56150: [Backport #12741]
    
    * thread.c (rb_threadptr_raise): set cause from the called thread,
      but not from the thread to be interrupted.
      [ruby-core:77222] [Bug #12741]
    
    * test/ruby/test_exception.rb: fix thread issues.
      * use Queue instead of a local variable for synchronization.
      * join created thread to soleve leaking threads warning.

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/eval.c
    branches/ruby_2_3/test/ruby/test_exception.rb
    branches/ruby_2_3/thread.c
    branches/ruby_2_3/version.h
Index: ruby_2_3/thread.c
===================================================================
--- ruby_2_3/thread.c	(revision 58025)
+++ ruby_2_3/thread.c	(revision 58026)
@@ -2073,6 +2073,8 @@ rb_threadptr_ready(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L2073
     rb_threadptr_interrupt(th);
 }
 
+void rb_threadptr_setup_exception(rb_thread_t *th, VALUE mesg, VALUE cause);
+
 static VALUE
 rb_threadptr_raise(rb_thread_t *th, int argc, VALUE *argv)
 {
@@ -2088,6 +2090,7 @@ rb_threadptr_raise(rb_thread_t *th, int https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L2090
     else {
 	exc = rb_make_exception(argc, argv);
     }
+    rb_threadptr_setup_exception(GET_THREAD(), exc, Qundef);
     rb_threadptr_pending_interrupt_enque(th, exc);
     rb_threadptr_interrupt(th);
     return Qnil;
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 58025)
+++ ruby_2_3/version.h	(revision 58026)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.3"
 #define RUBY_RELEASE_DATE "2017-03-20"
-#define RUBY_PATCHLEVEL 247
+#define RUBY_PATCHLEVEL 248
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_3/test/ruby/test_exception.rb
===================================================================
--- ruby_2_3/test/ruby/test_exception.rb	(revision 58025)
+++ ruby_2_3/test/ruby/test_exception.rb	(revision 58026)
@@ -703,6 +703,54 @@ end.join https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_exception.rb#L703
     assert_equal('d', e.cause.message, 'cause option should be honored always')
   end
 
+  def test_cause_thread_no_cause
+    bug12741 = '[ruby-core:77222] [Bug #12741]'
+
+    x = Thread.current
+    a = false
+    y = Thread.start do
+      Thread.pass until a
+      x.raise "stop"
+    end
+
+    begin
+      raise bug12741
+    rescue
+      e = assert_raise_with_message(RuntimeError, "stop") do
+        a = true
+        sleep 1
+      end
+    end
+    assert_nil(e.cause)
+  end
+
+  def test_cause_thread_with_cause
+    bug12741 = '[ruby-core:77222] [Bug #12741]'
+
+    x = Thread.current
+    q = Queue.new
+    y = Thread.start do
+      q.pop
+      begin
+        raise "caller's cause"
+      rescue
+        x.raise "stop"
+      end
+    end
+
+    begin
+      raise bug12741
+    rescue
+      e = assert_raise_with_message(RuntimeError, "stop") do
+        q.push(true)
+        sleep 1
+      end
+    ensure
+      y.join
+    end
+    assert_equal("caller's cause", e.cause.message)
+  end
+
   def test_unknown_option
     bug = '[ruby-core:63203] [Feature #8257] should pass unknown options'
 
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 58025)
+++ ruby_2_3/ChangeLog	(revision 58026)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Mon Mar 20 05:47:49 2017  Koichi Sasada  <ko1@a...>
+
+	* test/ruby/test_exception.rb: fix thread issues.
+	  * use Queue instead of a local variable for synchronization.
+	  * join created thread to soleve leaking threads warning.
+
+Mon Mar 20 05:47:49 2017  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (rb_threadptr_raise): set cause from the called thread,
+	  but not from the thread to be interrupted.
+	  [ruby-core:77222] [Bug #12741]
+
 Wed Feb  8 02:17:02 2017  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/forwardable.rb (Forwardable._delegator_method): extract
Index: ruby_2_3/eval.c
===================================================================
--- ruby_2_3/eval.c	(revision 58025)
+++ ruby_2_3/eval.c	(revision 58026)
@@ -581,6 +581,17 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/ruby_2_3/eval.c#L581
     }
 }
 
+void
+rb_threadptr_setup_exception(rb_thread_t *th, VALUE mesg, VALUE cause)
+{
+    if (cause == Qundef) {
+	cause = get_thread_errinfo(th);
+    }
+    if (cause != mesg) {
+	rb_ivar_set(mesg, id_cause, cause);
+    }
+}
+
 static void
 rb_longjmp(int tag, volatile VALUE mesg, VALUE cause)
 {

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r56125


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

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