diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-16 16:47:24 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-16 16:47:24 +0000 |
commit | 886142e8eecec4956b4f5d1d3fa8761dba1cd7d1 (patch) | |
tree | 43e3d0d381c80db32296e2ca5fb7c68e2065f072 /test | |
parent | 37e3fd88020a7259ddc027b22bbad0e91c67ed65 (diff) |
merge revision(s) r43942,r43957,r43975: [Backport #9187]
* hash.c (rb_hash_rehash): fix to free new st_table when exception
is raised in do_hash(). [Bug #9187]
* 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.
* array.c (rb_hash_rehash): use hash_alloc() instead of rb_hash_new().
[Bug #9187]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 c84ee74adf..a77c5cf43f 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -993,6 +993,34 @@ class TestHash < Test::Unit::TestCase end 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 |