diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-30 08:06:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-30 08:06:51 +0000 |
commit | 48384bbab7acd23742cd6c516811573eb3ef3c83 (patch) | |
tree | 0143c731047727360a49c10842c6e99667385093 /test | |
parent | b6d7233d53ac1e12914c705d6811d9ffccc50be1 (diff) | |
download | ruby-48384bbab7acd23742cd6c516811573eb3ef3c83.tar.gz |
parse.y: pin down dynamic symbol only
* parse.y (rb_id_attrset): pin down dynamic symbol only. it is
possibe that attrset ID can be registered as a static symbol
after the corresponding attrget ID has been registered as a
dynamic, and then the latter may be collected.
[ruby-core:62226] [Bug #9787]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_symbol.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index 686b74d1e7..e74c41cd2d 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -237,4 +237,22 @@ class TestSymbol < Test::Unit::TestCase '', child_env: '--disable-gems') end + + def test_gc_attrset + bug9787 = '[ruby-core:62226] [Bug #9787]' + assert_normal_exit(<<-'end;', '', child_env: '--disable-gems') + def noninterned_name(prefix = "") + prefix += "_#{Thread.current.object_id.to_s(36).tr('-', '_')}" + begin + name = "#{prefix}_#{rand(0x1000).to_s(16)}_#{Time.now.usec}" + end while Symbol.find(name) or Symbol.find(name + "=") + name + end + n = noninterned_name("gc") + n.to_sym + GC.start(immediate_sweep: false) + eval(":#{n}=") + eval("proc{self.#{n} = nil}") + end; + end end |