php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5734 Segfault when installed as DSO
Submitted: 2000-07-22 13:12 UTC Modified: 2000-07-26 22:40 UTC
From: anil at recoil dot org Assigned:
Status: Closed Package: Installation problem
PHP Version: 4.0 Latest CVS (22/07/2000) OS: OpenBSD-2.7-STABLE
Private report: No CVE-ID: None
 [2000-07-22 13:12 UTC] anil at recoil dot org
Compile goes fine (--with-apxs=/usr/sbin/apxs --enable-versioning --without-mysql) until the very end:

/bin/sh /usr/local/src/cvs/php4/libtool --silent --mode=compile gcc  -DHAVE_CONFIG_H -I. -I/usr/local/src/cvs/php4/ -I/usr/local/src/cvs/php4 -I/usr/local/src/cvs/php4/main -I/usr/lib/apache/include -I/usr/local/src/cvs/php4/Zend -I/usr/local/src/cvs/php4 -I/usr/local/src/cvs/php4/ext/xml/expat/xmltok -I/usr/local/src/cvs/php4/ext/xml/expat/xmlparse  -DEAPI=1 -DXML_BYTE_ORDER=12 -g -O2  -c stub.c
/bin/sh /usr/local/src/cvs/php4/libtool --silent --mode=link gcc  -DHAVE_CONFIG_H -I. -I/usr/local/src/cvs/php4/ -I/usr/local/src/cvs/php4 -I/usr/local/src/cvs/php4/main -I/usr/lib/apache/include -I/usr/local/src/cvs/php4/Zend -I/usr/local/src/cvs/php4 -I/usr/local/src/cvs/php4/ext/xml/expat/xmltok -I/usr/local/src/cvs/php4/ext/xml/expat/xmlparse  -DEAPI=1 -DXML_BYTE_ORDER=12 -g -O2   -o libphp4.la -rpath /usr/local/src/cvs/php4/libs -export-symbols /usr/local/src/cvs/php4/sapi/apache/php.sym -avoid-version   stub.lo  Zend/libZend.la  sapi/apache/libsapi.la  main/libmain.la  regex/libregex.la  ext/db/libdb.la ext/pcre/libpcre.la ext/posix/libposix.la ext/session/libsession.la ext/standard/libstandard.la ext/xml/libxml.la   -lresolv -lm -lresolv

*** Warning: inter-library dependencies are not known to be supported.
*** All declared inter-library dependencies are being dropped.
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.
ld: .libs/libphp4.lax/libsapi.al/mod_php4.lo: relocation must refer to global symbol at 0xf2b
ld: .libs/libphp4.lax/libsapi.al/mod_php4.lo: relocation must refer to global symbol at 0xec8
ld: .libs/libphp4.lax/libsapi.al/mod_php4.lo: relocation must refer to global symbol at 0xe9b
ld: .libs/libphp4.lax/libsapi.al/mod_php4.lo: relocation must refer to global symbol at 0xc22
Making all in pear

Then, attempting to start Apache with a LoadModule causes a segfault.  a gdb backtrace reveals nothing of use:

Core was generated by `httpd'.
Program terminated with signal 11, Segmentation fault.
#0  0x0 in ?? ()

Ktracing the program and kdumping reveals:

 29446 httpd    NAMI  "/var/www/logs/ssl_scache.db"
 29446 httpd    RET   unlink -1 errno 2 No such file or directory
 29446 httpd    CALL  unlink(0xad054)
 29446 httpd    NAMI  "/var/www/logs/ssl_scache.db"
 29446 httpd    RET   unlink -1 errno 2 No such file or directory
 29446 httpd    CALL  unlink(0xad074)
 29446 httpd    NAMI  "/var/www/logs/ssl_scache.dir"
 29446 httpd    RET   unlink -1 errno 2 No such file or directory
 29446 httpd    CALL  unlink(0xad094)
 29446 httpd    NAMI  "/var/www/logs/ssl_scache.pag"
 29446 httpd    RET   unlink -1 errno 2 No such file or directory
 29446 httpd    CALL  unlink(0xad0b4)
 29446 httpd    NAMI  "/var/www/logs/ssl_scache.db"
 29446 httpd    RET   unlink -1 errno 2 No such file or directory
 29446 httpd    CALL  unlink(0xbd134)
 29446 httpd    NAMI  "/var/www/logs/ssl_scache"
 29446 httpd    RET   unlink -1 errno 2 No such file or directory
 29446 httpd    CALL  unlink(0xbd154)
 29446 httpd    NAMI  "/var/www/logs/ssl_mutex.29446"
 29446 httpd    RET   unlink -1 errno 2 No such file or directory
 29446 httpd    PSIG  SIGSEGV SIG_DFL
 29446 httpd    NAMI  "httpd.core"



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-23 02:15 UTC] anil at recoil dot org
There are reports on the OpenBSD list that this
problem only occurs on OpenBSD when PHP is installed
as a DSO.  Unfortunately, statically compiling it in
requires patching the source tree, and means that
PHP3 and 4 cannot be used together, and also makes
it impossible to package PHP4 in the ports tree.

If any of the PHP developers could look at this problem
it would help us OpenBSD users quite a bit :)
 [2000-07-25 01:06 UTC] anil at recoil dot org
Some more information - I recompiled Apache with debugging symbols with a --without-execstrip, and generated a slightly better backtrace:

bash-2.04# gdb /usr/sbin/httpd ./httpd.core
GNU gdb 4.16.1
Copyright 1996 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-openbsd2.7"...
Core was generated by `httpd'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/libexec/ld.so...done.
Reading symbols from /usr/lib/libc.so.25.0...done.
Reading symbols from /usr/lib/apache/modules/libphp4.so...done.
#0  0x4017e428 in sapi_startup (sf=0xcb000) at SAPI.c:77
77              sapi_module = *sf;
(gdb) bt
#0  0x4017e428 in sapi_startup (sf=0xcb000) at SAPI.c:77
#1  0x40174661 in php_init_handler (s=0x81034, p=0x8100c) at mod_php4.c:698
#2  0x256d0 in ap_init_modules ()
#3  0x3533b in main ()


 [2000-07-26 22:28 UTC] anil at recoil dot org
Rob Black <rob@ivision.co.uk> and I tracked down this bug.  It comes from a little bit of confusion in the definition of the sapi_module_struct.

It is defined as an extern in main/SAPI.h, and a variable of the _same name_ is redefined as a static in sapi/apache/mod_php4.c

The linker then fails to relocate this due to the confusion at dynamic link time.  Below is a simple patch to rename the static variable in mod_php4.c to sapi_module_conf, which removes the variable conflict.

If this could be tested and committed soon it would enable the running of PHP4 as a DSO under OpenBSD. 

Index: sapi/apache/mod_php4.c
===================================================================
RCS file: /repository/php4/sapi/apache/mod_php4.c,v
retrieving revision 1.59
diff -u -r1.59 mod_php4.c
--- sapi/apache/mod_php4.c      2000/07/10 09:20:35     1.59
+++ sapi/apache/mod_php4.c      2000/07/26 20:29:09
@@ -321,7 +321,7 @@
 }
 
 
-static sapi_module_struct sapi_module = {
+static sapi_module_struct sapi_module_conf = {
        "apache",                                               /* name */
        "Apache",                                               /* pretty name */
                                                                        
@@ -576,8 +576,8 @@
 #ifdef ZTS
                tsrm_startup(1, 1, 0);
 #endif
-               sapi_startup(&sapi_module);
-               php_apache_startup(&sapi_module);
+               sapi_startup(&sapi_module_conf);
+               php_apache_startup(&sapi_module_conf);
        }
        per_dir_entry.type = mode;
 
@@ -661,7 +661,7 @@
 static void apache_php_module_shutdown_wrapper(void)
 {
        apache_php_initialized = 0;
-       sapi_module.shutdown(&sapi_module);
+       sapi_module.shutdown(&sapi_module_conf);
 
 #if MODULE_MAGIC_NUMBER >= 19970728
        /* This function is only called on server exit if the apache API
@@ -679,7 +679,7 @@
 static void php_child_exit_handler(server_rec *s, pool *p)
 {
 /*     apache_php_initialized = 0; */
-       sapi_module.shutdown(&sapi_module);
+       sapi_module.shutdown(&sapi_module_conf);
 
 #ifdef ZTS
        tsrm_shutdown();
@@ -695,8 +695,8 @@
 #ifdef ZTS
                tsrm_startup(1, 1, 0);
 #endif
-               sapi_startup(&sapi_module);
-               php_apache_startup(&sapi_module);
+               sapi_startup(&sapi_module_conf);
+               php_apache_startup(&sapi_module_conf);
        }
 #if MODULE_MAGIC_NUMBER >= 19980527
        {
 [2000-07-26 22:40 UTC] rasmus@php.net
Patch applied - thanks
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 03:02:51 2024 UTC