[#35027] [Ruby 1.9-Bug#4352][Open] [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s) — "James M. Lawrence" <redmine@...>

Bug #4352: [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s)

16 messages 2011/02/01

[#35114] [Ruby 1.9-Bug#4373][Open] http.rb:677: [BUG] Segmentation fault — Christian Fazzini <redmine@...>

Bug #4373: http.rb:677: [BUG] Segmentation fault

59 messages 2011/02/06

[#35171] [Ruby 1.9-Bug#4386][Open] encoding: directive does not affect regex expressions — mathew murphy <redmine@...>

Bug #4386: encoding: directive does not affect regex expressions

9 messages 2011/02/09

[#35237] [Ruby 1.9-Bug#4400][Open] nested at_exit hooks run in strange order — Suraj Kurapati <redmine@...>

Bug #4400: nested at_exit hooks run in strange order

12 messages 2011/02/15

[ruby-core:35360] Re: eval'ing large strings runs out of stack space?

From: Kurt Stephens <ks@...>
Date: 2011-02-24 03:40:08 UTC
List: ruby-core #35360
On 2/23/11 9:24 PM, Kurt Stephens wrote:
>
> #inspect isn't the problem:
>
>  > ruby-1.9.2-p136 --version -e '(['000000000']*500000).inspect'
> ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
>

The sweet spot is ~ 130000 element arrays:

  > ./ruby -v -e 'eval((["000000000"] * 130950).inspect)'
ruby 1.9.3dev (2010-08-20 trunk 29060) [x86_64-darwin10.4.0]
(eval):0: stack level too deep (SystemStackError)

And it's invariant of String size:

  > ./ruby -v -e 'eval((["0"] * 130950).inspect)'
ruby 1.9.3dev (2010-08-20 trunk 29060) [x86_64-darwin10.4.0]
(eval):0: stack level too deep (SystemStackError)

> My guess (I don't know 1.9 very well, yet.):
>
> The issue may be related to the parse.y args -> aref_args production.
> the args grammar production is left-recursive.
>
> http://www.gnu.org/software/bison/manual/html_node/Recursion.html
>
> "Any kind of sequence can be defined using either left recursion or
> right recursion, but you should always use left recursion, because it
> can parse a sequence of any number of elements with bounded stack space.
> Right recursion uses up space on the Bison stack in proportion to the
> number of elements in the sequence, because all the elements must be
> shifted onto the stack before the rule can be applied even once. See The
> Bison Parser Algorithm, for further explanation of this. "
>

Oops: The args grammar production *is* left-recursive so this might not 
be one of the underlying causes.

-- KAS

In This Thread