From 401c8bb00be23a6485a068add70e01419673a91e Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 29 Dec 2014 02:18:20 +0000 Subject: thread.c: fix dynamic symbol keys * 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_thread.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index fba4737009..87d5f0f79e 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -432,6 +432,16 @@ class TestThread < Test::Unit::TestCase 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 -- cgit v1.2.3