|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-02-26 22:21 UTC] chris at seismo dot usbr dot gov dot spamfree
Description:
------------
NSAPI with old versions of Netscape Enterprise Server (3 and 4) bombs when the server tries to load it. PHP-cli works fine. And if one removes the load statements from obj.conf, the server has no problem (and no PHP). On Irix 6.5, the startup error with PHP NSAPI is "PANIC pt_bootstrap() Couldn't INIT_THREADS - {0x0, 0x0}".
The basic problem here is that NS/Iplanet versions 3 and 4 do not support pthreads whereas PHP requires them (sort of). See article:
http://kb.netscape.com/NASApp/kb/Article?id=2861
Although NS/Iplanet has threads, they are not pthreads. To get a working NSAPI, one must use NSAPI threads instead.
That's a big problem because TSRM wants pthreads. So the issue is simply how to build NSAPI without pthreads.
It can be done with 3 simple fixes: (1) TSRM fixes; (2) use correct configure flags; (3) configure hacks.
(Note that php-cli needs to be built separately)
##### FIRST
TSRM.h mostly *has* support for NSAPI threads, it's just that the pthread ifdef's are reached first. Also, a couple of lines are missing. Here are the few simple code changes that are needed (sorry, I don't have CVS):
In NSAPI.h change
#elif defined(PTHREADS)
# define THREAD_T pthread_t
# define MUTEX_T pthread_mutex_t *
#elif defined(PI3WEB)
to
#elif defined(PTHREADS)
# define THREAD_T pthread_t
# define MUTEX_T pthread_mutex_t *
#elif defined(NSAPI)
# define THREAD_T SYS_THREAD
# define MUTEX_T CRITICAL
#elif defined(PI3WEB)
In TSRM.c, change
#elif defined(NSAPI)
return crit_enter(mutexp)
#elif defined(PI3WEB)
to
#elif defined(NSAPI)
crit_enter(mutexp); /* returns void */
return crit_enter(mutexp);
#elif defined(PI3WEB)
and also change
#elif defined(NSAPI)
return crit_exit(mutexp);
#elif defined(PI3WEB)
to
#elif defined(NSAPI)
crit_exit(mutexp); /* returns void */
return 0;
#elif defined(PI3WEB)
In nsapi.h, be sure to define XP_UNIX, or do it in configure.
##### SECOND
Make sure the following flags are given to configure:
--with-nsapi=/your/path/to/Netscape/3.5 --without-tsrm-pthreads --disable-cli --without-pear
##### THIRD
Configure needs to be modified for several things to disable any use of pthreads and set CFLAGS for NSAPI threads:
(1) For NS 3 and 4, don't use pthreads
(2) Make sure CFLAGS="$CFLAGS -DNSAPI -DXP_UNIX"
(3) Make sure -lpthread is never used
(4) Make sure there's no pthread support in main/php_config.h
A quick, if ugly hack to configure that does that is to change occurrences of
if test "$cross_compiling" = yes"; then
to
if test "$cross_compiling" = yes -o "ugly" = "ugly" ; then
A more elegant fix would change sapi/nsapi/config.m4 to reflect the logic: if (NS3 or 4) -> no pthreads, and define(NSAPI and XP_UNIX).
Build and install following the instructions in the PHP manual for NSAPI, and that's it.
This appears to have been a problem many others have had (e.g., bugs 4982, 13174, 10821, 4504, 6939, 9612, 2019, 10012, 25517, 11039, 11174, 12258, 5120, 23269, 6439, 11656, 4404, 14634, 6196, 18701, 12466, 16418, 15439, 16996, 5536, 8376). Hope this helps.
Expected result:
----------------
./ns-httpd -d config
Netscape-Enterprise/3.5.1 B98.027.1047
startup: listening to http://our.web.server, port 80 as web
Actual result:
--------------
./ns-httpd -d config
Netscape-Enterprise/3.5.1 B98.027.1047
startup: listening to http://our.web.server, port 80 as web
PANIC pt_bootstrap() Couldn't INIT_THREADS - {0x0, 0x0}
(pt_bootstrap is from libpthreads.so on IRIX).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 03:00:02 2025 UTC |
Corrections/typos: (1) NSAPI.h should read TSRM.h (2) Fix for TSRM.c should read #elif defined(NSAPI) crit_enter(mutexp); /* returns void */ return 0; #elif defined(PI3WEB) (3) Also need to disable test for $pthreads_working in configure NSAPI section: enable_experimental_zts=yes # if test "$pthreads_working" != "yes"; then # { echo "configure: error: ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads." 1>&2; exit 1; } # fi (4) sapi/nsapi/config.m4 is semi-busted even without the NSAIP thread/pthread bug: change if test -d $PHP_NSAPI/include ; then NSAPI_INCLUDE=$PHP_NSAPI/include AC_MSG_RESULT(Netscape-Enterprise 3.x style) AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h]) fi to if test -d $PHP_NSAPI/include ; then NSAPI_INCLUDE=$PHP_NSAPI/include AC_MSG_RESULT(Netscape-Enterprise 3.x style) AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h]) NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE" dnl basic bug fix AC_DEFINE(NSAPI,1,[ ]) dnl partial pthread fix AC_DEFINE(XP_UNIX,1,[ ]) dnl partial pthread fix fi In configure, these lines would be change fi if test -d $PHP_NSAPI/plugins/include ; then test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE" to CFLAGS="$CFLAGS -DNSAPI -DXP_UNIX" NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE" fi if test -d $PHP_NSAPI/plugins/include ; then test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE" sapi/nsapi/config.m4 needs a more general fix though, including modifying the macro PHP_BUILD_THREAD_SAFE for NS3 and 4 to require enable_experimental_zts=yes, but not pthread.TSRM.c needed a few more minor changes to have complete NSAPI support. Without these, you eventually get SIGSEGV. The point of these changes is to permit choice of using NSAPI thread API, thus avoiding dependency on native threads (and resulting problems on some platforms). Here are the complete context diffs for php-4.3.5RC3: *** 91,96 **** --- 91,98 ---- #if defined(PTHREADS) /* Thread local storage */ static pthread_key_t tls_key; + #elif defined(NSAPI) + static int tls_key; #elif defined(TSRM_ST) static int tls_key; #elif defined(TSRM_WIN32) *************** *** 106,111 **** --- 108,115 ---- pth_init(); #elif defined(PTHREADS) pthread_key_create( &tls_key, 0 ); + #elif defined(NSAPI) + tls_key = systhread_newkey(); #elif defined(TSRM_ST) st_init(); st_key_create(&tls_key, 0); *************** *** 186,191 **** --- 190,197 ---- #elif defined(PTHREADS) pthread_setspecific(tls_key, 0); pthread_key_delete(tls_key); + #elif defined(NSAPI) + /* systhread_setdata(tls_key, 0); /* as bogus as pthread_setspecific(key,0) */ #elif defined(TSRM_WIN32) TlsFree(tls_key); #endif *************** *** 261,266 **** --- 267,274 ---- #if defined(PTHREADS) /* Set thread local storage to this new thread resources structure */ pthread_setspecific(tls_key, (void *) *thread_resources_ptr); + #elif defined(NSAPI) + systhread_setdata(tls_key, (void *) *thread_resources_ptr); #elif defined(TSRM_ST) st_thread_setspecific(tls_key, (void *) *thread_resources_ptr); #elif defined(TSRM_WIN32) *************** *** 302,307 **** --- 310,317 ---- * and our hashtable lookup. */ thread_resources = pthread_getspecific(tls_key); + #elif defined(NSAPI) + thread_resources = systhread_getdata(tls_key); #elif defined(TSRM_ST) thread_resources = st_thread_getspecific(tls_key); #elif defined(TSRM_WIN32) *************** *** 390,395 **** --- 400,407 ---- } #if defined(PTHREADS) pthread_setspecific(tls_key, 0); + #elif defined(NSAPI) + /* systhread_setdata(tls_key, 0); /* as bogus as pthread_setspecific(key,0) */ #elif defined(TSRM_WIN32) TlsSetValue(tls_key, 0); #endif *************** *** 524,530 **** #elif defined(PTHREADS) return pthread_mutex_lock(mutexp); #elif defined(NSAPI) ! return crit_enter(mutexp); #elif defined(PI3WEB) return PISync_lock(mutexp); #elif defined(TSRM_ST) --- 536,543 ---- #elif defined(PTHREADS) return pthread_mutex_lock(mutexp); #elif defined(NSAPI) ! crit_enter(mutexp); /* returns void */ ! return 0; #elif defined(PI3WEB) return PISync_lock(mutexp); #elif defined(TSRM_ST) *************** *** 551,557 **** #elif defined(PTHREADS) return pthread_mutex_unlock(mutexp); #elif defined(NSAPI) ! return crit_exit(mutexp); #elif defined(PI3WEB) return PISync_unlock(mutexp); #elif defined(TSRM_ST) --- 564,571 ---- #elif defined(PTHREADS) return pthread_mutex_unlock(mutexp); #elif defined(NSAPI) ! crit_exit(mutexp); /* returns void */ ! return 0; #elif defined(PI3WEB) return PISync_unlock(mutexp); #elif defined(TSRM_ST) For completeness, here are the context diffs for TSRM.h: *** 45,50 **** --- 45,52 ---- # include <pth.h> #elif defined(PTHREADS) # include <pthread.h> + #elif defined(NSAPI) + # include <nsapi.h> #elif defined(TSRM_ST) # include <st.h> #elif defined(BETHREADS) As discribed above, configure still needs hacking to turn off pthreads and get the proper defines. If I get a chance, I'll make the m4 changes to do that cleanly, and post those as well.