diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-02 12:59:31 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-02 12:59:31 +0000 |
commit | ead0c5d356dd84acf3ad8a7f41f6b5bf2fb363c5 (patch) | |
tree | 5b65804464e28e99810adc0354872ec4d796708c /test/ruby | |
parent | 39a8519a569bd2190422c4a340950ccd5bbc7f04 (diff) | |
download | ruby-ead0c5d356dd84acf3ad8a7f41f6b5bf2fb363c5.tar.gz |
* hash.c (rb_hash_rehash): make temporary st_table under the control
of GC. [Bug #9187]
* test/ruby/test_hash.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_hash.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index cfb61b6480..656b026f4a 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1080,6 +1080,34 @@ class TestHash < Test::Unit::TestCase assert_not_equal([a,"hello"].hash, [b,"world"].hash, bug9151) end + def test_exception_in_rehash + bug9187 = '[ruby-core:58728] [Bug #9187]' + + prepare = <<-EOS + class Foo + def initialize + @raise = false + end + + def hash + raise if @raise + @raise = true + return 0 + end + end + EOS + + code = <<-EOS + h = {Foo.new => true} + 10_0000.times do + h.rehash rescue nil + end + GC.start + EOS + + assert_no_memory_leak([], prepare, code, bug9187) + end + class TestSubHash < TestHash class SubHash < Hash end |