Bug #9151
closedSegfault in Ruby head
Description
Following code causes a segfault in ruby head on x64:
class A
attr_accessor :b
def hash
[b,""].hash
end
end
class B
attr_accessor :a
def hash
[a,""].hash
end
end
a = A.new
b = B.new
a.b = b
b.a = a
p a.hash
p b.hash
p [a,"hello"].hash == [b,"world"].hash
Updated by nobu (Nobuyoshi Nakada) about 11 years ago
It's a simple machine stack overflow.
What's your platform?
Updated by Hanmac (Hans Mackowiak) about 11 years ago
its a similar error to #9003
p a.hash # raises Stack Error
p b.hash # Segmentation fault: 11
happens for:
ruby 2.1.0dev (2013-11-26 trunk 43854) [x86_64-darwin12.0]
does not happen for:
ruby 2.1.0dev (2013-09-22 trunk 43011) [i686-linux]
Updated by sam.saffron (Sam Saffron) about 11 years ago
@nobu (Nobuyoshi Nakada) running in ubuntu latest x64
Updated by nobu (Nobuyoshi Nakada) about 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r43859.
Sam, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
hash.c: cut off if recursion
- hash.c (rb_hash): cut off if recursion detected to get rid of stack
overflow. [ruby-core:58567] [Bug #9151]