YAML BUG

H

haldane

Does anyone know why this program causes YAML to go into an infinite
loop until it runs out of stack?

http://194.100.133.72/rubytest/t.rb.txt


I tried it with the latest cvs snapshot - ruby 1.9.0 (2004-06-29)
[i686-linux]

(I'm trying to get yaml to sucessfully dump an instiki wiki.)

Stephen Sykes
 
H

haldane

Does anyone know why this program causes YAML to go into an infinite

I have a much shorter example now:

require 'yaml'
class A
attr_accessor :b,:c
def initialize
@f = "h" * 2000
@g = $x
end
end

$x = A.new

a = A.new
a.b = A.new
a.b.b = A.new
a.b.c = a

# yaml goes into an infinite loop
y a

My theory is that yaml keeps a track of objects, and only assigns them
an id number if it sees the object for the second time (in emitter.c).
If it does this, it tries to go back and write that id where the
object first occurred. But if the 4k buffer has already been exceeded
and flushed, then the id cannot be written, and the whole object is
written out again. Causing an infinite loop.

This is a serious problem. If my theory is right, I guess it could be
fixed by always writing an id for every object in the expectation that
it may be met again?

_why: any comments?

Stephen Sykes
 
W

why the lucky stiff

haldane said:
My theory is that yaml keeps a track of objects, and only assigns them
an id number if it sees the object for the second time (in emitter.c).
If it does this, it tries to go back and write that id where the
object first occurred. But if the 4k buffer has already been exceeded
and flushed, then the id cannot be written, and the whole object is
written out again. Causing an infinite loop.

This is definitely the problem.
This is a serious problem. If my theory is right, I guess it could be
fixed by always writing an id for every object in the expectation that
it may be met again?

This solution would make for a lot of ugly YAML. Too big of a tradeoff
for the lesser case of large recursive elements.

I'll just collect IDs for all the collections in a tree before emitting.
Ok, it's etched into the schedule. Thank you!

_why
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,248
Latest member
MagdalenaB

Latest Threads

Top