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

ruby-changes:37044

From: naruse <ko1@a...>
Date: Sat, 3 Jan 2015 21:20:13 +0900 (JST)
Subject: [ruby-changes:37044] naruse:r49125 (ruby_2_2): merge revision(s) 49055: [Backport #10667]

naruse	2015-01-03 21:20:06 +0900 (Sat, 03 Jan 2015)

  New Revision: 49125

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

  Log:
    merge revision(s) 49055: [Backport #10667]
    
    * thread.c (rb_thread_variable_get): fix dynamic symbol keys.
      rb_check_id() returns non-zero only for static symbols, whereas
      thread local variable keys can be dynamic symbols.
      [ruby-core:67185] [Bug #10667]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/test/-ext-/symbol/test_inadvertent_creation.rb
    branches/ruby_2_2/test/ruby/test_thread.rb
    branches/ruby_2_2/thread.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 49124)
+++ ruby_2_2/ChangeLog	(revision 49125)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Sat Jan  3 21:17:58 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (rb_thread_variable_get): fix dynamic symbol keys.
+	  rb_check_id() returns non-zero only for static symbols, whereas
+	  thread local variable keys can be dynamic symbols.
+	  [ruby-core:67185] [Bug #10667]
+
 Thu Jan  1 08:29:55 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* cygwin/GNUmakefile.in (EXTOBJS): override to add resource files
Index: ruby_2_2/thread.c
===================================================================
--- ruby_2_2/thread.c	(revision 49124)
+++ ruby_2_2/thread.c	(revision 49125)
@@ -2936,11 +2936,9 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/thread.c#L2936
 rb_thread_variable_get(VALUE thread, VALUE key)
 {
     VALUE locals;
-    ID id = rb_check_id(&key);
 
-    if (!id) return Qnil;
     locals = rb_ivar_get(thread, id_locals);
-    return rb_hash_aref(locals, ID2SYM(id));
+    return rb_hash_aref(locals, rb_to_symbol(key));
 }
 
 /*
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 49124)
+++ ruby_2_2/version.h	(revision 49125)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.0"
-#define RUBY_RELEASE_DATE "2015-01-01"
-#define RUBY_PATCHLEVEL 5
+#define RUBY_RELEASE_DATE "2015-01-03"
+#define RUBY_PATCHLEVEL 6
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 1
+#define RUBY_RELEASE_DAY 3
 
 #include "ruby/version.h"
 
Index: ruby_2_2/test/ruby/test_thread.rb
===================================================================
--- ruby_2_2/test/ruby/test_thread.rb	(revision 49124)
+++ ruby_2_2/test/ruby/test_thread.rb	(revision 49125)
@@ -432,6 +432,16 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_thread.rb#L432
     end
   end
 
+  def test_thread_local_dynamic_symbol
+    bug10667 = '[ruby-core:67185] [Bug #10667]'
+    t = Thread.new {}.join
+    key_str = "foo#{rand}"
+    key_sym = key_str.to_sym
+    t.thread_variable_set(key_str, "bar")
+    assert_equal("bar", t.thread_variable_get(key_str), "#{bug10667}: string key")
+    assert_equal("bar", t.thread_variable_get(key_sym), "#{bug10667}: symbol key")
+  end
+
   def test_select_wait
     assert_nil(IO.select(nil, nil, nil, 0.001))
     t = Thread.new do
Index: ruby_2_2/test/-ext-/symbol/test_inadvertent_creation.rb
===================================================================
--- ruby_2_2/test/-ext-/symbol/test_inadvertent_creation.rb	(revision 49124)
+++ ruby_2_2/test/-ext-/symbol/test_inadvertent_creation.rb	(revision 49125)
@@ -202,7 +202,13 @@ module Test_Symbol https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/-ext-/symbol/test_inadvertent_creation.rb#L202
       Thread.current.thread_variable_set(:test, nil)
       name = noninterned_name
       assert_nil(Thread.current.thread_variable_get(name))
-      assert_not_interned(name)
+      assert_not_pinneddown(name)
+    end
+
+    def test_thread_variable_set
+      name = noninterned_name
+      Thread.current.thread_variable_set(name, 42)
+      assert_not_pinneddown(name)
     end
 
     def test_thread_variable?

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


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

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