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

ruby-changes:46036

From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 02:13:53 +0900 (JST)
Subject: [ruby-changes:46036] usa:r58107 (ruby_2_2): merge revision(s) 56125, 56150: [Backport #12741]

usa	2017-03-26 02:13:49 +0900 (Sun, 26 Mar 2017)

  New Revision: 58107

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

  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_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/eval.c
    branches/ruby_2_2/test/ruby/test_exception.rb
    branches/ruby_2_2/thread.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 58106)
+++ ruby_2_2/version.h	(revision 58107)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 439
+#define RUBY_PATCHLEVEL 440
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2/eval.c
===================================================================
--- ruby_2_2/eval.c	(revision 58106)
+++ ruby_2_2/eval.c	(revision 58107)
@@ -595,6 +595,17 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/ruby_2_2/eval.c#L595
     }
 }
 
+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)
 {
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 58106)
+++ ruby_2_2/ChangeLog	(revision 58107)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Sun Mar 26 02:13:04 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.
+
+Sun Mar 26 02:13:04 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]
+
 Sat Mar 25 23:35:54 2017  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/forwardable.rb (Forwardable._delegator_method): extract
Index: ruby_2_2/test/ruby/test_exception.rb
===================================================================
--- ruby_2_2/test/ruby/test_exception.rb	(revision 58106)
+++ ruby_2_2/test/ruby/test_exception.rb	(revision 58107)
@@ -696,6 +696,52 @@ end.join https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_exception.rb#L696
     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
+    a = false
+    y = Thread.start do
+      Thread.pass until a
+      begin
+        raise "caller's cause"
+      rescue
+        x.raise "stop"
+      end
+    end
+
+    begin
+      raise bug12741
+    rescue
+      e = assert_raise_with_message(RuntimeError, "stop") do
+        a = true
+        sleep 1
+      end
+    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_2/thread.c
===================================================================
--- ruby_2_2/thread.c	(revision 58106)
+++ ruby_2_2/thread.c	(revision 58107)
@@ -2046,6 +2046,8 @@ rb_threadptr_ready(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/thread.c#L2046
     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)
 {
@@ -2061,6 +2063,7 @@ rb_threadptr_raise(rb_thread_t *th, int https://github.com/ruby/ruby/blob/trunk/ruby_2_2/thread.c#L2063
     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;

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


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

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