From: Robert Klemme Date: 2004-01-15T21:26:35+09:00 Subject: Re: YAML bug: ruby 1.8.1 (2003-12-05) [i686-linux] "Andrew Walrond" schrieb im Newsbeitrag news:200401151124.23571.andrew@walrond.org... > When dumping a Hash containing a string with a length greater than about 4100, > ruby segfaults: > > ... > 4099 > 4100 > 4101 > 4102 > 4103 > /pkg/ruby.2/lib/ruby/1.8/yaml.rb:193: [BUG] Segmentation fault > ruby 1.8.1 (2003-12-05) [i686-linux] > > Easily reproduced here with simple test > > #!/bin/ruby > > require 'yaml' > > len = 1 > while true > a = {"test"=>'x'*len} > puts len > b = YAML.dump(a) > len += 1 > end > > > I've tried two different machines; The magic number of one is 4103 and the > other is 4175 > > This is coincidentally close to a 4k buffer perhaps??? This happens on cygwin: 8187 8188 8189 8190 8191 8192 /usr/lib/ruby/1.8/yaml/rubytypes.rb:315:in `simple': failed to allocate memory ( NoMemoryError) from /usr/lib/ruby/1.8/yaml/rubytypes.rb:315:in `to_yaml' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:293:in `call' from /usr/lib/ruby/1.8/yaml.rb:188:in `quick_emit' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:293:in `to_yaml' from /usr/lib/ruby/1.8/yaml/baseemitter.rb:175:in `map' from /usr/lib/ruby/1.8/yaml/baseemitter.rb:164:in `each' from /usr/lib/ruby/1.8/yaml/baseemitter.rb:164:in `map' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:60:in `to_yaml' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:55:in `call' from /usr/lib/ruby/1.8/yaml.rb:188:in `quick_emit' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:55:in `to_yaml' from /usr/lib/ruby/1.8/yaml.rb:31:in `dump' from ./yaml-bug.rb:10 13:04:39 [ruby]: ruby -v ruby 1.8.1 (2003-12-25) [i386-cygwin] These behave identical (mem allocation error): #!/bin/ruby # hash created outside of loop require 'yaml' len = 1 a={} while true a["test"] = 'x'*len puts len b = YAML.dump(a) len += 1 end #!/bin/ruby # only one string instance require 'yaml' str = '' while true a = {"test"=>str} puts str.length b = YAML.dump(a) str << 'x' end #!/bin/ruby # only 1 string and 1 Hash require 'yaml' str = '' a = {} while true a["test"]=str puts str.length b = YAML.dump(a) str << 'x' end Regards robert