# Yaml bug(?) in pre2

**URL:** <https://rubytalk.org/t/yaml-bug-in-pre2/12971>\
**Category:** ruby-talk\
**Created:** [9 August 2004 17:46 UTC](https://rubytalk.org/t/yaml-bug-in-pre2/12971 "2004-08-09T17:46:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Pirker](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@Martin\_Pirker](https://rubytalk.org/u/Martin_Pirker)\
**Post date:** [9 August 2004 17:46 UTC](https://rubytalk.org/t/yaml-bug-in-pre2/12971/1 "2004-08-09T17:46:17Z")

</div>

given: large dataset  
dump via .to\_yaml  
read back from file with YAML::load(f)

runs ok write+read with  
V1: ruby 1.8.1 (2004-05-02) [i686-linux-gnu]  
V2: ruby 1.8.2 (2004-07-16) [i686-linux] (aka pre1)

broken with  
V3: ruby 1.8.2 (2004-07-29) [i686-linux] (aka pre2)

V3 reads dump produced by V1+V2 ok  
V1+V2 crash on reading dump from V3

cut down testcase, structure dumped with V3:

------------------------ cut here ------------------------

> **···**
>
> ---  
> "sfdfdsdsffsdsfdfd":  
> &nbsp;&nbsp;-  
> &nbsp;&nbsp;&nbsp;&nbsp;-  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;whatever:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- something  
> &nbsp;&nbsp;&nbsp;&nbsp;- \>+  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cdvfd: fddfdddd
> 
> &nbsp;&nbsp;&nbsp;&nbsp;- |
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Using M2, Opera's revolutionary e-mail client: [http://www.opera.com/m2/](http://www.opera.com/m2/)
> 
> &nbsp;&nbsp;- 999999999  
> ------------------------ cut here ------------------------
> 
> crash on reading:
> 
> irb(main):038:0\> File::open("yamltest","r") do |f| YAML::load(f) end  
> ArgumentError: parse error on line 14, col 51: Using M2, Opera's revolutionary e-mail client: [http://www.opera.com/m2/](http://www.opera.com/m2/)'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/lib/ruby/1.8/yaml.rb:119:in 'load'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/lib/ruby/1.8/yaml.rb:119:in 'load'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):38  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):38:in en'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):38  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from :0
> 
> the problem appears to be the indentation of "test", if one moves it some  
> spaces to front it works:
> 
> irb(main):037:0\> File::open("yamltest","r") do |f| YAML::load(f) end  
> =\> {"sfdfdsdsffsdsfdfd"=\>[[{"whatever"=\>["something"]}, "cdvfd: fddfdddd\n\n",  
> "\ntest\n\n--\nUsing M2, Opera's revolutionary e-mail client: [http://www.opera.com/m2/\n](http://www.opera.com/m2/%5Cn)"],  
> 999999999]}
> 
> yaml dumper from V1+V2 dumps text segment in one line with \..\.. inserts  
> and proper spaces for indentation
> 
> testing with V4: ruby 1.8.2 (2004-08-08) [i686-linux] taken from CVS
> 
> dump runs
> 
> reading back in only gives size 2:  
> irb(main):010:0\> s = File::open("mydump","r") do |f| YAML::load(f) end  
> irb(main):011:0\> puts s.size  
> 2
> 
> trying to read dump from V1+V2 gives:  
> ArgumentError: parse error on line 172, col 300:.....
> 
> which is a one line string with lotsa \...\... and he seems to choke on  
> an umlaut u (sorry can't type that on my terminal now)
> 
> so, can anybody read the file from V4?  
> V3 can't, V4 seems do dump the same multiline text like V3, so of course V3 chokes
> 
> reverting back to V2:  
> irb(main):004:0\> s = File::open("mydumpv2","r") do |f| YAML::load(f) end  
> irb(main):005:0\> puts s.size  
> 1077
> 
> yep, that's how it should be
> 
> Ruby versions from Gentoo, if that matters
> 
> so after ~4 hours hunting:  
> V3 emitter seems to be broken and introduces bug with texts which are dumped as  
> multiline and don't start at first column  
> V4 only reads in 2 obj instead of 1000+ and chokes on the upper testcase too
> 
> I give up  
> staying with V2 which is the last worksforme[tm] and will replace the  
> dump/restore routine with a homegrown, after all it isn't a good idea to  
> yaml so large datasets - gives pretty 100Mb memory fragmentation...
> 
> Martin
