Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000485 [Resin] minor always 12-06-05 18:21 02-02-06 15:39
Reporter spatula1 View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 3.0.14
Summary 0000485: Resin on FreeBSD may compile against the wrong threading library
Description Starting in FreeBSD 5.1, users may choose from one of three threading libraries, the default of which is libpthread, no longer libc_r. The other choice is libthr. To make matters more interesting, libmap.conf allows users to specify which threading library to substitute for another at runtime. So even if a binary is compiled against libpthread, it can be coerced to run against libc_r at runtime.

Unfortunately, if multiple threading libraries are in use in a single program, chaos results. This can happen with the Resin JNI library if it is compiled against a different threading library than the one used by Java. It is necessary to detect which threading library is in use and compile against that one.

The default threading library in FreeBSD 5 and later is libpthread.
Additional Information Here's a patch, albeit a bit messy, that illustrates a way to detect the correct threading library to use:

--- configure.orig Tue Dec 6 16:25:21 2005
+++ configure Tue Dec 6 17:58:29 2005
@@ -8739,7 +8739,65 @@
        ;;
 
   *freebsd*)
- PROXY_LIBS='-lc_r'
+
+ freebsd_version_major=`uname -r | sed -e 's/\([0-9]\{1,\}\).*/\1/'`
+ freebsd_version_minor=`uname -r | sed -e 's/^[0-9]\{1,\}\.\([0-9]\{1,\}\).*/\1/'`
+
+ if [ \( $freebsd_version_major -gt 5 \) -o \( $freebsd_version_major -eq 5 -a $freebsd_version_minor -ge 1 \) ]
+ then
+ echo Using FreeBSD ${freebsd_version_major}.${freebsd_version_minor}\; checking which threading library to use
+
+ if [ `file -L $JAVA_HOME/bin/java | grep -c "shell script"` -eq 1 ]
+ then
+ echo "You must specify --with-java-home ($JAVA_HOME/bin/java is a wrapper script)"
+ exit
+ fi
+
+ if [ `file -L $JAVA_HOME/bin/java | grep -c "Linux"` -eq 1 -a "${enable_jni+set}" = set ]
+ then
+ echo "Cannot build JNI library for Linux VM (use native FreeBSD VM or disable JNI)"
+ exit
+ fi
+
+ if [ `file -L $JAVA_HOME/bin/java | grep -c "Linux"` -eq 0 ]
+ then
+ thread_lib=`ldd $JAVA_HOME/bin/java | sed 's/.*=>//' | grep -c libc_r`
+ thread_lib=${thread_lib}`ldd $JAVA_HOME/bin/java | sed 's/.*=>//' | grep -c libpthread`
+ thread_lib=${thread_lib}`ldd $JAVA_HOME/bin/java | sed 's/.*=>//' | grep -c libthr`
+ case "$thread_lib" in
+ 100)
+ PROXY_LIBS='-lc_r'
+ ;;
+ 010)
+ PROXY_LIBS='-lpthread'
+ ;;
+ 001)
+ PROXY_LIBS='-lthr'
+ ;;
+ *)
+ echo "Can't figure out which threading library is in use by Java!"
+ exit;
+ ;;
+ esac
+
+ echo
+ echo Using ${PROXY_LIBS} for threading.
+ echo
+ echo "NOTE: If you change Java's thread library via libmap.conf(5) or a recompile,"
+ echo you MUST configure and compile Resin again!
+ echo
+ echo "ALSO NOTE: if you're using the threading MP model in Apache 2, you must use"
+ echo the same threading library for Apache as you use in Java, or manually edit
+ echo the Makefile to ensure that the correct threading library is linked to
+ echo mod_caucho. Use ldd on the httpd binary to determine which threading
+ echo library is in use.
+ echo
+
+ fi
+ else
+ PROXY_LIBS='-lc_r'
+ fi
+
         jni_os=freebsd
        ;;
 
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
12-06-05 18:21 spatula1 New Issue
02-02-06 15:39 ferg Assigned To  => ferg
02-02-06 15:39 ferg Status new => closed
02-02-06 15:39 ferg Resolution open => fixed
02-02-06 15:39 ferg Fixed in Version  => 3.0.18
02-02-06 15:39 ferg View Status @0@ => public


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
27 total queries executed.
25 unique queries executed.
Powered by Mantis Bugtracker