OSSP CVS Repository

ossp - Ticket #121
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Attach]  [Edit]  [History

Ticket 121: random segfaults in multithreaded application


we are experiencing random segfaults in our multithreaded application.

i traced this back to the fact that JS is not compiled against NSPR.

since we use glib/gthread for threading, JS native (asm) locks segfault too
and only NSPR locks work correctly.

the patch below implements a configure option to compile against a (std)
installed "mozilla-devel/mozilla-nspr-devel" via mozilla-config or a custom
install location.

it also propagates the required changes to js.pc and js-config.



--- js-1.6.20060820/configure.ac        2006-08-20 17:45:13.000000000 +0200
+++ js-1.6.20060820.nspr/configure.ac   2006-08-29 16:40:27.000000000 +0200
@@ -26,7 +26,7 @@
 dnl ##  configure.ac: GNU Autoconf source script
 dnl ##

-AC_PREREQ(2.60)
+AC_PREREQ(2.59)
 AC_INIT
 JS_VERSION=`./shtool version -l txt -d short VERSION`
 $ac_confdir/shtool echo -e \
@@ -55,6 +55,9 @@
     *mingw* | *windows* | *winnt* ) CPPFLAGS="$CPPFLAGS -DXP_WIN"  ;;
     *                             ) CPPFLAGS="$CPPFLAGS -DXP_UNIX" ;;
 esac
+
+CFG_CFLAGS="$CPPFLAGS"
+
 CPPFLAGS="$CPPFLAGS -DEXPORT_JS_API"

 dnl #   configure option --with-version
@@ -160,11 +163,36 @@
     CPPFLAGS="$CPPFLAGS -DJS_C_STRINGS_ARE_UTF8"
 fi

+dnl #   configure option --with-nspr[=path]
+AC_ARG_WITH([nspr],
+    AC_HELP_STRING([--with-nspr], [build threadsafe library with nspr]),
+    [ac_cv_with_nspr=$withval], [ac_cv_with_nspr=no])
+AC_CACHE_CHECK([whether to build threadsafe with nspr],
+    [ac_cv_with_nspr], [ac_cv_with_nspr=no])
+if test ".$ac_cv_with_nspr" != ".no"; then
+    case "$ac_cv_with_nspr" in
+        /* )
+                CPPFLAGS="$CPPFLAGS -DJS_THREADSAFE -DJS_USE_ONLY_NSPR_LOCKS -I$ac_cv_with_nspr/include"
+                LDFLAGS="$LDFLAGS -L$ac_cv_with_nspr/lib "
+                LIBS="$LIBS -lplc4 -lplds4 -lnspr4"
+        ;;
+        * )
+                AC_PATH_PROG(MOZILLA_CONFIG, mozilla-config, no)
+                if test "$MOZILLA_CONFIG" != "no" ; then
+                        CPPFLAGS="$CPPFLAGS -DJS_THREADSAFE -DJS_USE_ONLY_NSPR_LOCKS `$MOZILLA_CONFIG --cflags nspr`"
+                        LIBS="$LIBS `$MOZILLA_CONFIG --libs nspr`"
+                fi
+        ;;
+    esac
+    CFG_CFLAGS="$CFG_CFLAGS -DJS_THREADSAFE"
+fi
+
 AC_SUBST(CLI_CFLAGS)
 AC_SUBST(CLI_CPPFLAGS)
 AC_SUBST(CLI_LDFLAGS)
 AC_SUBST(CLI_LIBS)
 AC_SUBST(CLI_OBJS)
+AC_SUBST(CFG_CFLAGS)

 with_tags=""
 sinclude(libtool.m4)
--- js-1.6.20060820/js.pc.in    2006-07-24 21:53:01.000000000 +0200
+++ js-1.6.20060820.nspr/js.pc.in       2006-08-29 16:41:02.000000000 +0200
@@ -7,4 +7,4 @@
 Description: Mozilla JavaScript Engine
 Version: @JS_VERSION@
 Libs: -L${libdir} -ljs @LIBS@
-Cflags: -DOSSP -DXP_UNIX -I${includedir}/js
+Cflags: @CFG_CFLAGS@ -I${includedir}/js
--- js-1.6.20060820/js-config.sh.in     2006-08-10 21:55:51.000000000 +0200
+++ js-1.6.20060820.nspr/js-config.sh.in        2006-08-29 16:41:44.000000000 +0200
@@ -109,7 +109,7 @@
             output="$output $js_acdir"
             ;;
         --cppflags)
-            output="$output -DOSSP -DXP_UNIX -I$js_includedir/js"
+            output="$output @CFG_CFLAGS@ -I$js_includedir/js"
             ;;
         --cflags)
             : # none

[Add remarks]

Remarks:

Properties:

Type: code           Version: 1.6.20060820 
Status: new          Created: 2006-Aug-29 17:04
Severity:          Last Change: 2006-Aug-31 14:45
Priority:          Subsystem: js 
Assigned To: rse           Derived From:  
Creator: anonymous 

CVSTrac 2.0.1