ports/81464: ruby-1.8.2_3 stack handling broken due to libpthread linkage

Yoshiaki Kasahara kasahara at nc.kyushu-u.ac.jp
Mon Jan 16 09:14:30 UTC 2006


I have just upgraded to ruby-1.8.4_1,1 (now my system is 6.0R BTW),
and noticed the stack size has become even narrower.  Now the test
script in my report can iterate only 340 times (and crashes).

339
340
zsh: 7600 illegal hardware instruction (core dumped)  ruby test.rb

Here is a simple patch to change configure args when WITHOUT_PTHREAD
is defined.  Ruby always has its own thread mechanism (I believe it
doesn't use pthread for its thread mechanism anyway), so I changed the
name of the variable from "WITHOUT_THREADS" to "WITHOUT_PTHREAD".


diff -ur ruby18.o/Makefile ruby18/Makefile
--- ruby18.o/Makefile   Sun Jan 15 03:57:17 2006
+++ ruby18/Makefile     Mon Jan 16 16:32:45 2006
@@ -39,8 +39,14 @@
 GNU_CONFIGURE= yes
 WRKSRC=                ${RUBY_WRKSRC}
 CONFIGURE_ARGS=        ${RUBY_CONFIGURE_ARGS} \
-               --enable-shared --enable-pthread \
+               --enable-shared \
                --with-openssl-include=${OPENSSLINC}
+
+.if defined(WITHOUT_PTHREAD)
+CONFIGURE_ARGS+=       --disable-pthread
+.else
+CONFIGURE_ARGS+=       --enable-pthread
+.endif
 
 .if defined(DEBUG)
 CFLAGS+=       -g


And now it iterates over 50,000 times and correctly detects stack
overflow (limit stacksize = 64MB).

51013
51014
test.rb:4:in `print': stack level too deep (SystemStackError)
        from test.rb:4:in `rec'
        from test.rb:5:in `rec'
        from test.rb:8
zsh: 17193 exit 1     ruby test.rb

I'm sorry I'm not sure about compatibility issues with ruby-opengl,
ruby-wx etc because I don't use these ports.  I have only used the
binary (without pthread) on my own system.

When a binary is compiled with -pthread, the effective stack size is
(greatly) reduced because the program runs inside a thread, and
getrlimit() doesn't return the actual stack size.  So, Ruby cannot
detect the stack overflow.



More information about the freebsd-ports-bugs mailing list