Date: Wed, 25 May 2005 21:23:21 +0900 (JST) From: Yoshiaki Kasahara <kasahara@nc.kyushu-u.ac.jp> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/81464: ruby-1.8.2_3 stack handling broken due to libpthread linkage Message-ID: <200505251223.j4PCNL5j016419@elvenbow.nc.kyushu-u.ac.jp> Resent-Message-ID: <200505251230.j4PCU2l7084745@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 81464 >Category: ports >Synopsis: ruby-1.8.2_3 stack handling broken due to libpthread linkage >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed May 25 12:30:02 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Yoshiaki Kasahara >Release: FreeBSD 5.4-RELEASE i386 >Organization: Kyushu University >Environment: System: FreeBSD elvenbow.nc.kyushu-u.ac.jp 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Thu May 12 11:13:40 JST 2005 root@elvenbow.nc.kyushu-u.ac.jp:/usr/obj/usr/src/sys/ELVENBOW i386 >Description: Running a deeply recursive script on ruby-1.8.2_3 causes "illegal hardware instruction" due to stack overflow. The Ruby interpreter should detect the overflow but it can't. Expanding the process stacksize has no effect. The effective stack size seems to be about 1MB. There is no such problem with ruby16. I suspect it is caused by unconditional linkage with libpthread specified in /usr/ports/lang/ruby18/Makefile. >How-To-Repeat: Run the following (permanently recursive) code with various setting of 'limit stacksize'. #!/usr/local/bin/ruby def rec(a) print "#{a}\n" rec(a+1) end rec(1) Even with stacksize=64MB, it crashes before 1000 iterations. With ruby16 (built without pthread), it goes far deeper and also detects stack overflow correctly (raise SystemStackError exception). >Fix: Remove CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}" and LIB="${PTHREAD_LIBS}" from CONFIGURE_ENV. I don't know well about pthread, but I suspect there is (fixed?) stacksize limitation per thread. Probably Ruby doesn't know about that, and cannot detect the stack overflow. I'm sorry I'm not sure about issues with ruby-sdl and ruby-opengl etc mentioned in the CVS log. By the way, I noticed that Debian Linux had pthread enabled Ruby and it correctly detected stack overflow with larger process stacksize. Does it depend on libpthread implementation? >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505251223.j4PCNL5j016419>