Project

General

Profile

Bug #9187

st_table leaks when exception is raised in Hash#rehash

Added by Glass_saga (Masaki Matsushita) over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.1.0dev (2013-12-01 trunk 43941) [x86_64-linux]
[ruby-core:58728]

Description

Following code causes leakage of st_table:

class Foo
  def initialize
    @raise = false
  end

  def hash
    raise if @raise
    @raise = true
    return 0
  end
end

h = {Foo.new => true}
10_0000.times do
  h.rehash rescue nil
end

Associated revisions

Revision bfbe1b9b
Added by glass over 4 years ago

  • hash.c (rb_hash_rehash): fix to free new st_table when exception is raised in do_hash(). [Bug #9187]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 43942
Added by glass over 4 years ago

  • hash.c (rb_hash_rehash): fix to free new st_table when exception is raised in do_hash(). [Bug #9187]

Revision 43942
Added by Glass_saga (Masaki Matsushita) over 4 years ago

  • hash.c (rb_hash_rehash): fix to free new st_table when exception is raised in do_hash(). [Bug #9187]

Revision 43942
Added by glass over 4 years ago

  • hash.c (rb_hash_rehash): fix to free new st_table when exception is raised in do_hash(). [Bug #9187]

Revision 43942
Added by glass over 4 years ago

  • hash.c (rb_hash_rehash): fix to free new st_table when exception is raised in do_hash(). [Bug #9187]

Revision 43942
Added by glass over 4 years ago

  • hash.c (rb_hash_rehash): fix to free new st_table when exception is raised in do_hash(). [Bug #9187]

Revision ead0c5d3
Added by glass over 4 years ago

  • 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

Revision 43957
Added by glass over 4 years ago

  • 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.

Revision 43957
Added by Glass_saga (Masaki Matsushita) over 4 years ago

  • 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.

Revision 43957
Added by glass over 4 years ago

  • 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.

Revision 43957
Added by glass over 4 years ago

  • 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.

Revision 43957
Added by glass over 4 years ago

  • 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.

Revision 437b8bc5
Added by glass over 4 years ago

  • 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/trunk@43975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 43975
Added by glass over 4 years ago

  • array.c (rb_hash_rehash): use hash_alloc() instead of rb_hash_new(). [Bug #9187]

Revision 43975
Added by Glass_saga (Masaki Matsushita) over 4 years ago

  • array.c (rb_hash_rehash): use hash_alloc() instead of rb_hash_new(). [Bug #9187]

Revision 43975
Added by glass over 4 years ago

  • array.c (rb_hash_rehash): use hash_alloc() instead of rb_hash_new(). [Bug #9187]

Revision 43975
Added by glass over 4 years ago

  • array.c (rb_hash_rehash): use hash_alloc() instead of rb_hash_new(). [Bug #9187]

Revision 43975
Added by glass over 4 years ago

  • array.c (rb_hash_rehash): use hash_alloc() instead of rb_hash_new(). [Bug #9187]

Revision 90d94de3
Added by usa (Usaku NAKAMURA) over 4 years ago

merge revision(s) 43942,43957,43975: [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_1_9_3@44938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 886142e8
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

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

History

#1 Updated by Anonymous over 4 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43942.
Masaki, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • hash.c (rb_hash_rehash): fix to free new st_table when exception is raised in do_hash(). [Bug #9187]

#2 [ruby-core:60703] Updated by usa (Usaku NAKAMURA) over 4 years ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED to 1.9.3: DONE, 2.0.0: REQUIRED

backported into ruby_1_9_3 at r44948.

#3 [ruby-core:60790] Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Backport changed from 1.9.3: DONE, 2.0.0: REQUIRED to 1.9.3: DONE, 2.0.0: DONE

r43942, r43957 and r43975 were backported to ruby_2_0_0 at r45011.

#4 [ruby-core:61407] Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Description updated (diff)

Also available in: Atom PDF