Regression: Hash#merge! in some cases leads to never-ending loop that consumes
entire available memory
------------------------------------------------------------------------------------------------------
Key: JRUBY-1604
URL: http://jira.codehaus.org/browse/JRUBY-1604
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.x
Environment: Ubuntu Linux 7.10 or WinVista,
JRuby from trunk rev.4987
Reporter: Vladimir Sizikov
Priority: Critical
The rev. 4987 (Hash changes) introduced a regression into Hash behavior.
Rubinius spec tests now hangs with JRuby until the memory is fully exhausted.
JRuby built from earlier sources works just fine (rev 4986).
Rubinius test verifies that: "Hash#merge does not affect yielded items by
removing the current element".
I investigated the failing/hanging test a bit, and here's the small test case
that shows the problem:
hsh = {1 => 2, 3 => 4, 5 => 6}
n = 3
h = Array.new(n) { hsh.dup }
args = Array.new(n) { |i| [h[i]] }
r = Array.new(n) { [] }
h[0].merge!(*args[0]) { |*x| r[0] << x; true }
h[1].merge!(*args[1]) { |*x| r[1] << x; h[1].shift; true }
h[2].merge!(*args[2]) { |*x| r[2] << x; h[2].delete(h[2].keys.first); true }
r[0..-1].each do |yielded|
#puts yielded.inspect
puts yielded == r[0]
end
Under MRI, it finishes quickly and produces true, true, true.
Under JRuby it hangs, with the following stack trace:
"main" prio=6 tid=0x01098000 nid=0x175c runnable [0x0259f000..0x0259fe40]
java.lang.Thread.State: RUNNABLE
at org.jruby.RubyArrayInvoker$aref_method_1_1.call(Unknown Source)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:144)
at
org.jruby.runtime.CallSite$ArgumentBoxingCallSite.call(CallSite.java:103)
at hash.closure4(hash.rb:12)
at hashBlockclosure4xx1.call(Unknown Source)
at
org.jruby.runtime.CompiledBlockLight.yield(CompiledBlockLight.java:124)
at
org.jruby.runtime.CompiledBlockLight.yield(CompiledBlockLight.java:105)
at org.jruby.runtime.Block.yield(Block.java:111)
at org.jruby.RubyHash$19.visit(RubyHash.java:1145)
at org.jruby.RubyHash.visitAll(RubyHash.java:488)
at org.jruby.RubyHash.merge_bang(RubyHash.java:1140)
at org.jruby.RubyHashInvoker$merge_bang_method_1_0.call(Unknown Source)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:158)
at hash.__file__(hash.rb:12)
at hash.load(hash.rb)
at org.jruby.Ruby.runScript(Ruby.java:588)
at org.jruby.Ruby.runNormally(Ruby.java:510)
at org.jruby.Ruby.runFromMain(Ruby.java:433)
at org.jruby.Main.runInterpreter(Main.java:227)
at org.jruby.Main.runInterpreter(Main.java:183)
at org.jruby.Main.run(Main.java:116)
at org.jruby.Main.run(Main.java:93)
at org.jruby.Main.main(Main.java:84)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email