bundler/bundler — pull request #2510 by headius (2013-06-23 14:07:23+00:00)
Title: Add and use a new catch/throw mechanism that's stack-friendly.

This new mechanism, dubbed "safe catch", uses a fiber or thread
every nth catch, to avoid blowing out the call stack. When used
in the resolver, this effectively reduces the maximum stack depth
needed to whatever depth 20 of the old recursions would have
consumed. On JRuby, this allows installing at 256k stack a Gemfile
that blew up at 512k. I would not expect any Gemfile to cause a
stack error on JRuby with this patch in place, and the stack load
on other implementations should be considerably reduced as well.

This partially addresses #2449 and related issues, but I'd still
like to see Bundler adopt an iterative algorithm, probably by
building a state machine, since it will not require this patch's
tricks and should never cause the excessively deep stacks of the
recursive version.