Bug #1813: Threading seg fault (1.9.1-p129 Linux/Mac)
http://redmine.ruby-lang.org/issues/show/1813

Author: Charlton Wang
Status: Open, Priority: Normal
ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]

I'm not sure if there is a thread stack limitation change that is new to 1.9.1 but the following code now causes a segfault on Linux and Illegal Instruction on the Mac. I know this code is somewhat ridiculous (call stack is attempting to go 1001 levels deep) but this seems to work fine in 1.8.6. If the code is executed outside of a thread, everything works fine as well.

t = Thread.new do
    n = 1000
    n.times do |i|
        Object.class_eval <<EOF
            define_method "foo#{i}" do
                if i < n-1
                    puts i
                    self.send("foo#{i+1}")
                else
                    puts "done"
                end
            end
EOF
    end
    foo0
end
t.join

Thanks,
Charlton


----------------------------------------
http://redmine.ruby-lang.org