Forum: Ruby-core [Bug #1813] Threading seg fault (1.9.1-p129 Linux/Mac)

Posted by Charlton Wang (Guest)
on 2009-07-23 23:02
(Received via mailing list)
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
Posted by Charlton Wang (Guest)
on 2009-07-23 23:03
(Received via mailing list)
Issue #1813 has been updated by Charlton Wang.


I should have realized that the 1.9 series uses native threads and I 
suspect that's likely the cause (presumably a stack size limitation?).
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1813
Posted by Roger Pack (Guest)
on 2010-01-27 02:01
(Received via mailing list)
Issue #1813 has been updated by Roger Pack.


seems to work fine for me with 1.9.1/1.9.2
Is it still a problem?
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1813
Posted by Yui NARUSE (Guest)
on 2010-01-27 08:46
(Received via mailing list)
Issue #1813 has been updated by Yui NARUSE.

Category set to core
Status changed from Feedback to Open

reproduced on both Ubuntu 8.04 x86_64 and FreeBSD 8.0 x86_64.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1813
Posted by Nobuyoshi Nakada (Guest)
on 2010-01-27 09:02
(Received via mailing list)
Issue #1813 has been updated by Nobuyoshi Nakada.


Seems like a stack overflow.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1813
Posted by Yusuke Endoh (Guest)
on 2010-05-13 18:27
(Received via mailing list)
Issue #1813 has been updated by Yusuke Endoh.

Status changed from Open to Closed
% Done changed from 0 to 100

This issue was solved with changeset r27789.
Charlton, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

----------------------------------------
http://redmine.ruby-lang.org/issues/show/1813
Posted by Ivan Pirlik (Guest)
on 2010-09-01 20:27
(Received via mailing list)
Issue #1813 has been updated by Ivan Pirlik.


I am still getting "Illegal Instruction" in 1.9.2-p0 on OSX 10.5.7 (on 
Ubuntu 9.10 x86_64 I get a SystemStackError, as expected).
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1813
Posted by "Iñaki Baz Castillo" <redmine@ruby-lang.org> (Guest)
on 2011-01-12 00:25
(Received via mailing list)
Issue #1813 has been updated by Iñaki Baz Castillo.


The given code produces a segmentation fault under ruby 1.9.2-p0 and 
1.9.2-p136 (tested in Ubuntu 64 bits). In 1.8 it doesn't crash:

(eval):3: [BUG] Segmentation fault
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]

-- control frame ----------
c:0917 p:---- s:1837 b:1837 l:001836 d:001836 CFUNC  :puts
c:0916 p:---- s:1835 b:1835 l:001834 d:001834 CFUNC  :puts
c:0915 p:0028 s:1831 b:1831 l:000978 d:001830 LAMBDA (eval):3
c:0914 p:---- s:1829 b:1829 l:001828 d:001828 FINISH
c:0913 p:0040 s:1827 b:1827 l:000978 d:001826 LAMBDA (eval):4
c:0912 p:---- s:1825 b:1825 l:001824 d:001824 FINISH
c:0911 p:0040 s:1823 b:1823 l:000978 d:001822 LAMBDA (eval):4
c:0910 p:---- s:1821 b:1821 l:001820 d:001820 FINISH
c:0909 p:0040 s:1819 b:1819 l:000978 d:001818 LAMBDA (eval):4
c:0908 p:---- s:1817 b:1817 l:001816 d:001816 FINISH
c:0907 p:0040 s:1815 b:1815 l:000978 d:001814 LAMBDA (eval):4
c:0906 p:---- s:1813 b:1813 l:001812 d:001812 FINISH
c:0905 p:0040 s:1811 b:1811 l:000978 d:001810 LAMBDA (eval):4
c:0904 p:---- s:1809 b:1809 l:001808 d:001808 FINISH
c:0903 p:0040 s:1807 b:1807 l:000978 d:001806 LAMBDA (eval):4
c:0902 p:---- s:1805 b:1805 l:001804 d:001804 FINISH
c:0901 p:0040 s:1803 b:1803 l:000978 d:001802 LAMBDA (eval):4
Posted by Motohiro KOSAKI (Guest)
on 2011-02-15 14:58
(Received via mailing list)
Issue #1813 has been updated by Motohiro KOSAKI.

Status changed from Closed to Open
Target version set to 1.9.x

This issue can be still reproduced on trunk. (ruby 1.9.3dev (2011-02-15 
trunk 30882) [x86_64-linux])

reopened.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.