The bug comes from this code: https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L275-296

Because the splat is expanded directly onto the stack, it's trivial for a splat to use up all the stack.

Rubinius had this bug back in the day, but we switched to holding a splatted array off the stack and making it available to the called method separately to avoid this bug. 

-- 
Evan Phoenix // evan / phx.io


On Tuesday, December 6, 2011 at 6:30 PM, Nick Quaranto wrote:

> 
> Issue #5719 has been reported by Nick Quaranto.
> 
> ----------------------------------------
> Bug #5719: Hash::[] can't handle 100000+ args
> http://redmine.ruby-lang.org/issues/5719
> 
> Author: Nick Quaranto
> Status: Open
> Priority: Normal
> Assignee: 
> Category: 
> Target version: 
> ruby -v: 1.9.3-p0
> 
> 
> I couldn't pin down an exact size for when/how this occurs, but I have code that was creating hashes just fine with Hash::[] with 300k+ arguments.
> 
> irb(main):056:0> (0...140000).map { |n| [:a, n] }.tap { |a| Hash[*a] }.size
> SystemStackError: stack level too deep
> from /Users/qrush/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/irb/workspace.rb:80
> Maybe IRB bug!
> irb(main):057:0> (0...130000).map { |n| [:a, n] }.tap { |a| Hash[*a] }.size
> => 130000
> 
> 
> 
> -- 
> http://redmine.ruby-lang.org