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

ruby-changes:42533

From: nagachika <ko1@a...>
Date: Sat, 16 Apr 2016 00:10:30 +0900 (JST)
Subject: [ruby-changes:42533] nagachika:r54607 (ruby_2_3): merge revision(s) 54598, 54600: [Backport #12290]

nagachika	2016-04-16 01:07:07 +0900 (Sat, 16 Apr 2016)

  New Revision: 54607

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

  Log:
    merge revision(s) 54598,54600: [Backport #12290]
    
    * thread.c (get_initialized_threadptr): extract ensuring that the
      thread is initialized.
    
    * thread.c (rb_thread_setname): thread must be initialized to set
      the name.  [ruby-core:74963] [Bug #12290]
    
    * thread.c (rb_thread_setname): defer setting native thread name
      set in initialize until the native thread is created.
      [ruby-core:74963] [Bug #12290]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/test/ruby/test_thread.rb
    branches/ruby_2_3/thread.c
    branches/ruby_2_3/thread_pthread.c
    branches/ruby_2_3/version.h
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 54606)
+++ ruby_2_3/version.h	(revision 54607)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.0"
-#define RUBY_RELEASE_DATE "2016-04-15"
-#define RUBY_PATCHLEVEL 81
+#define RUBY_RELEASE_DATE "2016-04-16"
+#define RUBY_PATCHLEVEL 82
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 4
-#define RUBY_RELEASE_DAY 15
+#define RUBY_RELEASE_DAY 16
 
 #include "ruby/version.h"
 
Index: ruby_2_3/thread_pthread.c
===================================================================
--- ruby_2_3/thread_pthread.c	(revision 54606)
+++ ruby_2_3/thread_pthread.c	(revision 54607)
@@ -1505,8 +1505,11 @@ native_set_thread_name(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread_pthread.c#L1505
 {
 #ifdef SET_CURRENT_THREAD_NAME
     if (!th->first_func && th->first_proc) {
-	VALUE loc = rb_proc_location(th->first_proc);
-	if (!NIL_P(loc)) {
+	VALUE loc;
+	if (!NIL_P(loc = th->name)) {
+	    SET_CURRENT_THREAD_NAME(RSTRING_PTR(loc));
+	}
+	else if (!NIL_P(loc = rb_proc_location(th->first_proc))) {
 	    const VALUE *ptr = RARRAY_CONST_PTR(loc); /* [ String, Fixnum ] */
 	    char *name, *p;
 	    char buf[16];
Index: ruby_2_3/test/ruby/test_thread.rb
===================================================================
--- ruby_2_3/test/ruby/test_thread.rb	(revision 54606)
+++ ruby_2_3/test/ruby/test_thread.rb	(revision 54607)
@@ -1082,4 +1082,10 @@ q.pop https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_thread.rb#L1082
     t.kill
     t.join
   end
+
+  def test_thread_setname_in_initialize
+    bug12290 = '[ruby-core:74963] [Bug #12290]'
+    c = Class.new(Thread) {def initialize() self.name = "foo"; super; end}
+    assert_equal("foo", c.new {Thread.current.name}.value)
+  end
 end
Index: ruby_2_3/thread.c
===================================================================
--- ruby_2_3/thread.c	(revision 54606)
+++ ruby_2_3/thread.c	(revision 54607)
@@ -711,6 +711,8 @@ thread_create_core(VALUE thval, VALUE ar https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L711
     return thval;
 }
 
+#define threadptr_initialized(th) ((th)->first_args != 0)
+
 /*
  * call-seq:
  *  Thread.new { ... }			-> thread
@@ -742,7 +744,7 @@ thread_s_new(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L744
 
     rb_obj_call_init(thread, argc, argv);
     GetThreadPtr(thread, th);
-    if (!th->first_args) {
+    if (!threadptr_initialized(th)) {
 	rb_raise(rb_eThreadError, "uninitialized thread - check `%"PRIsVALUE"#initialize'",
 		 klass);
     }
@@ -2794,7 +2796,9 @@ rb_thread_setname(VALUE thread, VALUE na https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L2796
     }
     th->name = name;
 #if defined(SET_ANOTHER_THREAD_NAME)
-    SET_ANOTHER_THREAD_NAME(th->thread_id, s);
+    if (threadptr_initialized(th)) {
+	SET_ANOTHER_THREAD_NAME(th->thread_id, s);
+    }
 #endif
     return name;
 }
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 54606)
+++ ruby_2_3/ChangeLog	(revision 54607)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Sat Apr 16 00:56:45 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (rb_thread_setname): defer setting native thread name
+	  set in initialize until the native thread is created.
+	  [ruby-core:74963] [Bug #12290]
+
 Fri Apr 15 21:10:00 2016  SHIBATA Hiroshi  <hsbt@r...>
 
 	* lib/irb/ext/save-history.rb: Fix NoMethodError when method is not defined.

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r54598,54600


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

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