diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-26 13:43:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-26 13:43:40 +0000 |
commit | d503381ce8ac41d91c195313ea1da5f67ba8250c (patch) | |
tree | 639cc6142aa5192b43b96d10d4fb7155d8de21b7 /test | |
parent | a4b0c3c26bcf7eab7c58b00eab2a75ed7d3c31b6 (diff) |
hash.c: cut off if recursion
* hash.c (rb_hash): cut off if recursion detected to get rid of stack
overflow. [ruby-core:58567] [Bug #9151]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_hash.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index c8cf5c6fbf..5f72dec5f4 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1060,6 +1060,20 @@ class TestHash < Test::Unit::TestCase end end + def test_recursive_hash_value + bug9151 = '[ruby-core:58567] [Bug #9151]' + + s = Struct.new(:x) {def hash; [x,""].hash; end} + a = s.new + b = s.new + a.x = b + b.x = a + ah = assert_nothing_raised(SystemStackError, bug9151) {a.hash} + bh = assert_nothing_raised(SystemStackError, bug9151) {b.hash} + assert_equal(ah, bh, bug9151) + assert_not_equal([a,"hello"].hash, [b,"world"].hash, bug9151) + end + class TestSubHash < TestHash class SubHash < Hash end |