[Q] YAML Error: stack level too deep

Hi Rubyists,

is there a solution for the:

`quick_emit': stack level too deep (SystemStackError)

Error?

OS: Win98
Ruby: 1.8.1

The whole error message:

C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml.rb:188:in `quick_emit': stack level too deep (SystemStackError)
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/rubytypes.rb:213:in `to_yaml'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/baseemitter.rb:175:in `map'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/baseemitter.rb:164:in `each'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/baseemitter.rb:164:in `map'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/rubytypes.rb:24:in `to_yaml'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/rubytypes.rb:23:in `call'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml.rb:188:in `quick_emit'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/rubytypes.rb:23:in `to_yaml'
   ... 1145 levels...
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/rubytypes.rb:23:in `call'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml.rb:188:in `quick_emit'
  from C:/RUBY SYSTEM/RUBY180/lib/ruby/1.8/yaml/rubytypes.rb:23:in `to_yaml'
  from X:/Diss/Programme/Test_netgen/rbF034.TMP:43

You're probably writing a very deep object graph, which uses up all the
stack.
One solution could be to write custom YAML emitters for some of your
classes, that writes the data in a more "flat" form (writing a tree of
objects as a list, etc.)
Look in the YAML source for how Ruby's built-in types are written to
YAML.

/Anders

···

--- "E.-R. Bruecklmeier" <unet01@radio-eriwan.de> wrote:

Hi Rubyists,

is there a solution for the:

`quick_emit': stack level too deep (SystemStackError)

Error?

=====
__________________________________________________
Anders Bengtsson ndrsbngtssn@yahoo.se
Stockholm, Sweden

Höstrusk och grå moln - köp en resa till solen på Yahoo! Resor på adressen http://se.docs.yahoo.com/travel/index.html

Anders Bengtsson schrieb:

You're probably writing a very deep object graph, which uses up all the
stack.
One solution could be to write custom YAML emitters for some of your
classes, that writes the data in a more "flat" form (writing a tree of
objects as a list, etc.)
Look in the YAML source for how Ruby's built-in types are written to
YAML.

Thank you, for the quick answer. But i don't want to go deeper in this matter, i'm just looking for a quick and dirty method to serialize large objects in a readable manner.

Eric.

I guess readability could be a problem, but you could attempt to
flatten the object graph even before attempting to serialize it. If you
have things like linked-lists you convert them to plain arrays, etc.
Or maybe you can increase the stack size in some way? (I don't know how
that's done in Windows).

/Anders

···

--- "E.-R. Bruecklmeier" <unet01@radio-eriwan.de> wrote:

Anders Bengtsson schrieb:
> You're probably writing a very deep object graph, which uses up all
the
> stack.
> One solution could be to write custom YAML emitters for some of
your
> classes, that writes the data in a more "flat" form (writing a tree
of
> objects as a list, etc.)

Thank you, for the quick answer. But i don't want to go deeper in
this
matter, i'm just looking for a quick and dirty method to serialize
large
objects in a readable manner.

=====
__________________________________________________
Anders Bengtsson ndrsbngtssn@yahoo.se
Stockholm, Sweden

Höstrusk och grå moln - köp en resa till solen på Yahoo! Resor på adressen http://se.docs.yahoo.com/travel/index.html

Anders Bengtsson <ndrsbngtssn@yahoo.se> wrote in message news:<20040706092327.9200.qmail@web50701.mail.yahoo.com>...

> Anders Bengtsson schrieb:
> > You're probably writing a very deep object graph, which uses up all
the
> > stack.

Actually you are almost certainly triggering a YAML bug which causes
it to go into an infinite loop.

See here:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/104976

And _why's response:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/105040

Stephen Sykes

···

--- "E.-R. Bruecklmeier" <unet01@radio-eriwan.de> wrote: