From: "ko1 (Koichi Sasada)" Date: 2013-12-16T11:10:16+09:00 Subject: [ruby-core:59125] [ruby-trunk - Bug #9252][Open] "RuntimeError: can't add a new key into hash during iteration" error on test-all of objspace Issue #9252 has been reported by ko1 (Koichi Sasada). ---------------------------------------- Bug #9252: "RuntimeError: can't add a new key into hash during iteration" error on test-all of objspace https://bugs.ruby-lang.org/issues/9252 Author: ko1 (Koichi Sasada) Status: Open Priority: Normal Assignee: ko1 (Koichi Sasada) Category: ext Target version: current: 2.1.0 ruby -v: ruby -v: ruby 2.1.0dev (2013-12-15 trunk 44222) [x64-mswin64_110] Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN 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). -- http://bugs.ruby-lang.org/