Project

General

Profile

Actions

Bug #9252

closed

"RuntimeError: can't add a new key into hash during iteration" error on test-all of objspace

Added by ko1 (Koichi Sasada) about 11 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby -v: ruby 2.1.0dev (2013-12-15 trunk 44222) [x64-mswin64_110]
[ruby-core:59125]

Description

Now, some platforms have the following errors on "test-all TESTS=objspace".

  1. Error:
    TestObjSpace#test_reachable_objects_from_root:
    RuntimeError: can't add a new key into hash during iteration
    C:/ko1/src/ruby/trunk/test/objspace/test_objspace.rb:109:in hash' C:/ko1/src/ruby/trunk/test/objspace/test_objspace.rb:109:in hash'
    C:/ko1/src/ruby/trunk/test/objspace/test_objspace.rb:109:in reachable_objects_from_root' C:/ko1/src/ruby/trunk/test/objspace/test_objspace.rb:109:in test_reachable_objects_from_root'

ruby -v: ruby 2.1.0dev (2013-12-15 trunk 44222) [x64-mswin64_110]

This problem is because of an issue of "ObjectSpace.reachable_objects_from_root".

This method traverse all objects and insert it into a hash object to use as Set.
To set hash object, a hash value is solved by the hash' method and it uses rb_exec_recursive' for some classes. `rb_exec_recursive' generates a hash object
internally and this value is modified accidentally. This is current my assumption.

For example, we track new objects after `ObjectSpace.reachable_objects_from_root'
and avoid collection of such newer objects can solve this issue, but it will introduce
performance impact (but this method is not performance critical, so it can be accepted).

Actions

Also available in: Atom PDF

Like0
Like0Like0