YAML bug: ruby 1.8.1 (2003-12-05) [i686-linux]

A

Andrew Walrond

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???

Andrew Walrond
 
T

ts

A> /pkg/ruby.2/lib/ruby/1.8/yaml.rb:193: [BUG] Segmentation fault
A> ruby 1.8.1 (2003-12-05) [i686-linux]

Well, probably the bug is corrected in the CVS version.

To be sure, run your program under the debugger and when it crash execute
the command `bt'



Guy Decoux
 
R

Robert Klemme

Andrew Walrond said:
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
 

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,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top