php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15703 Segfault due to missing ZEND_INIT_MODULE_GLOBALS() call
Submitted: 2002-02-24 17:45 UTC Modified: 2007-04-04 18:44 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ssruprai at hotmail dot com Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 4.2.3 OS: Red Hat Linux 7.1
Private report: No CVE-ID: None
 [2002-02-24 17:45 UTC] ssruprai at hotmail dot com
I tried to compile php 4.1.1 on RedHat Linux 7.1 with jdk 1.4 beta 2 and apache2 (2_0_28 beta) (because java was not working with apache 1.3.23) with these options:

****************************PHP**************************
./configure --with-apache=/usr/src/httpd-2_0_28 --with-mod_charset --with-config-file-path=/usr/local/lib/php/ --with-openssl --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-cpdflib --with-png-dir --with-jpeg-dir --with-tiff-dir --enable-ctype --with-curl --with-db3 --with-dom --enable-exif --enable-filepro --enable-ftp --with-gd --enable-gd-native-ttf --with-xpm-dir --with-freetype-dir=/usr --with-ttf --with-t1lib --with-gettext --with-gmp --with-hyperwave --with-iconv --with-imap --with-kerberos --with-imap-ssl --with-ircg --with-ldap --enable-mbstring --enable-mbstr-enc-trans --with-mcal=/usr/src/libmcal --with-mhash --with-mnogosearch=/usr/local/mnogosearch --with-mysql --with-pgsql --with-pspell --with-qtdom --enable-trans-sid --enable-shmop --with-snmp -enable-ucd-snmp-hack --enable-sockets --with-regex=php --with-swf --enable-wddx --with-expat-dir=/usr/local --enable-xslt --with-xslt-sablot --with-yaz --enable-yp --with-zip --with-pdflib --enable-versioning --with-tsrm-st --with-tsrm-pthreads --enable-track-vars --enable-overload --with-mcrypt --with-java --enable-sysvsem --enable-sysvshm --with-xmlrpc

but php didn't compile because I think source structure of apache 2.0 is different from apache 1.3.

So to try compiling php as apache shared module (libphp4.so) I compiled Apache 2.0 beta with these options:

***********************************APACHE 2*************
./configure  --enable-auth-anon --enable-auth-db --enable-auth-dbm --enable-auth-digest --enable-file-cache --enable-echo --enable-cache --enable-mem-cache --enable-example --enable-ext-filter --enable-case-filter --enable-case-filter-in --enable-mime-magic --enable-cern-meta --enable-expires --enable-usertrck --enable-unique-id --enable-ssl --enable-optional-hook-export --enable-optional-hook-import --enable-optional-fn-import --enable-optional-fn-export --enable-http --enable-dav --enable-cgi --enable-info --enable-dgid --enable-dav-fs --enable-vhost-alias --enable-speling --enable-actions --enable-rewrite

and then compiled php 4.1.1 with these options:

*******************************PHP************************ 
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mod_charset --with-config-file-path=/usr/local/lib/php/ --with-openssl --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-cpdflib --with-png-dir --with-jpeg-dir --with-tiff-dir --enable-ctype --with-curl --with-db3 --with-dom --enable-exif --enable-filepro --enable-ftp --with-gd --enable-gd-native-ttf --with-xpm-dir --with-freetype-dir=/usr --with-ttf --with-t1lib --with-gettext --with-gmp --with-hyperwave --with-iconv --with-imap --with-kerberos --with-imap-ssl --with-ircg --with-ldap --enable-mbstring --enable-mbstr-enc-trans --with-mcal=/usr/src/libmcal --with-mhash --with-mnogosearch=/usr/local/mnogosearch --with-mysql --with-pgsql --with-pspell --with-qtdom --enable-trans-sid --enable-shmop --with-snmp -enable-ucd-snmp-hack --enable-sockets --with-regex=php --with-swf --enable-wddx --with-expat-dir=/usr/local --enable-xslt --with-xslt-sablot --with-yaz --enable-yp --with-zip --with-pdflib --enable-versioning --with-tsrm-st --with-tsrm-pthreads --enable-track-vars --enable-overload --with-mcrypt --with-java --enable-sysvsem --enable-sysvshm --with-xmlrpc

and this time --with-xmlrpc option produced some errors so I removed --with-xmlrpc.

Finally, it compiled and a shared module was produced under apache modules directory. LoadModule php4_module entry was automatically made by php install in httpd.conf. I tried AddType application/x-httpd-php but It didn't work then after removing AddType I added this option to httpd.conf

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>

and then restarted apache but php didn't work and segmentation fault message was added to logs/error_log.
I tried to compile it again next day after removing old sources and installed files. But it didn't work and browser waited and waited and then some error like network error was produced by lynx browser. When I examined logs/error_log then same segmentation fault entries like these were added because of php failure..

**************************error_log******************
[Sat Feb 23 20:52:55 2002] [notice] child pid 703 exit 
signal Segmentation fault (11)
[Sat Feb 23 20:53:22 2002] [notice] child pid 706 exit 
signal Segmentation fault (11)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-24 22:22 UTC] yohgaki@php.net
To properly diagnose this bug, we need a backtrace to see what is
happening behind the scenes. To find out how to generate a backtrace,
please read http://bugs.php.net/bugs-generating-backtrace.php

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open".
 [2002-02-25 06:25 UTC] yohgaki@php.net
BTW, use apahce 2.0.31... That's the version you are suppose to use.
Read README file always _especially_ when you are using EXPERIMENTAL one.
 [2002-02-27 15:20 UTC] sukhruprai at yahoo dot com
I did read the README file in sapi/apache2filter directory. But I think it wasn't mentioned there that we should use Apache 2_0_31.

Anyway, I started from scratch again and tried each step one by one. I forgot to generate back trace but I will generate it next time. But this time I tried various configurations which are given below. In some cases php 4.1.1 and apache 2_0_28 did work.

FIRST CONFIGURATION
----------

---------------------Apache 2.0--------------
./configure --prefix=/wwwroot --enable-so

---------------------PHP 4.1.1-----------------
./configure --prefix=/wwwroot/php --with-mysql --with-java=/usr/java/j2sdk1.4.0

php did work and phpinfo() displayed information java library was loaded.
But when jver.php was accessed  lynx exited with following error:

Looking up localhost
Making HTTP connection to localhost
Sending HTTP request.
HTTP request sent; waiting for response.
Alert!: Unexpected network read error; connection aborted.
Can't Access `http://localhost/jver.php'
Alert!: Unable to access document.

nothing was added to logs/error_log or to php error log file (php error 
logging was enabled and a file name was specified)
no segmentation fault etc was entered in error log.

Then I did this:
export 
LD_LIBRARY_PATH=/usr/java/j2sdk1.4.0/jre/lib/i386/native_threads:/usr/java/j2sdk1.4.0/jre/lib/i386/client:/usr/java/j2sdk1.4.0/jre/lib/i386;

Every thing worked and when jver.php (sample file provided with java ext) was 
accessed java version etc. was displayed.

extension directory created was:
/wwwroot/php/lib/php/extensions/no-debug-zts-20010901/


Second Time
-----------

---------------Apache 2.0 Configure Options-------------------

./configure --prefix=/wwwroot --enable-auth-anon --enable-auth-db 
--enable-auth-dbm --enable-auth-digest --enable-file-cache --enable-echo 
--enable-cache --enable-mem-cache --enable-example --enable-ext-filter 
--enable-case-filter --enable-case-filter-in --enable-mime-magic 
--enable-cern-meta --enable-expires --enable-usertrack --enable-unique-id 
--enable-ssl --enable-optional-hook-export --enable-optional-hook-import 
--enable-optional-fn-import --enable-optional-fn-export --enable-http 
--enable-dav --enable-cgi --enable-info --enable-cgid --enable-dav-fs 
--enable-vhost-alias --enable-speling --enable-actions --enable-rewrite 
--enable-so

------------------------------PHP 4.1.1 ------------------------------
./configure --prefix=/wwwroot/php --with-mysql 
--with-java=/usr/java/j2sdk1.4.0 --with-apxs2=/wwwroot/bin/apxs 
--with-config-file-path=/wwwroot/php

phpinfo() worked and java library was loaded.
Java (jver.php) worked after exporting this:

export LD_LIBRARY_PATH=/usr/java/j2sdk1.4.0/jre/lib/i386/native_threads:/usr/java/j2sdk1.4.0/jre/lib/i386/client:/usr/java/j2sdk1.4.0/jre/lib/i386;

and displayed this:

Java version=1.4.0-beta
Java vendor=Sun Microsystems Inc.

OS=Linux 2.4.3-12 on i386
Wednesday, February 27, 2002 at 3:29:02 AM India Standard Time

But following was added to apache 2.0 error_log:

[Wed Feb 27 03:28:22 2002] [notice] Apache/2.0.28 (Unix) mod_ssl/3.0a0 
OpenSSL/0.9.6 DAV/2 configured -- resuming normal operations
[Wed Feb 27 03:29:03 2002] [error] Optional hook test said: GET /jver.php 
HTTP/1.0
[Wed Feb 27 03:29:03 2002] [error] Optional function test said: GET 
/jver.php HTTP/1.0
[Wed Feb 27 03:31:00 2002] [error] Optional hook test said: GET /jver.php 
HTTP/1.0
[Wed Feb 27 03:31:00 2002] [error] Optional function test said: GET 
/jver.php HTTP/1.0

------------
THIRD TIME
------------

Then I made a distclean in php-4.1.1 directory. stopped apache 2.0. 
Removed directory /wwwroot/php. And configured and installed php with 
following options..

------------------------------PHP 4.1.1 Configure---------------------
./configure --prefix=/wwwroot/php --with-apxs2=/wwwroot/bin/apxs 
--with-mod_charset --with-config-file-path=/wwwroot/php/ --with-openssl 
--with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-cpdflib 
--with-png-dir --with-jpeg-dir --with-tiff-dir --enable-ctype --with-curl 
--with-db3 --with-dom --enable-exif --enable-filepro --enable-ftp 
--with-gd --enable-gd-native-ttf --with-xpm-dir --with-freetype-dir=/usr --with-ttf 
--with-t1lib --with-gettext --with-gmp --with-hyperwave --with-iconv 
--with-imap --with-kerberos --with-imap-ssl --with-ircg --with-ldap 
--enable-mbstring --enable-mbstr-enc-trans --with-mcal=/usr/src/libmcal 
--with-mhash --with-mnogosearch=/usr/local/mnogosearch --with-mysql 
--with-pgsql --with-pspell --with-qtdom --enable-trans-sid --enable-shmop 
--with-snmp -enable-ucd-snmp-hack --enable-sockets --with-regex=php 
--with-swf --enable-wddx --with-expat-dir=/usr/local --enable-xslt 
--with-xslt-sablot --with-yaz=/usr/local/lib --enable-yp --with-zip 
--with-pdflib --enable-versioning --with-tsrm-st --with-tsrm-pthreads 
--enable-track-vars --enable-overload --with-mcrypt 
--with-java=/usr/java/j2sdk1.4.0 --enable-sysvsem --enable-sysvshm


This time when I restarted apache 2.0 php didn't work and lynx exited with 
same Unknown network error message. Following was added to apache logs/error_log


[Wed Feb 27 19:44:25 2002] [notice] Digest: done
[Wed Feb 27 19:44:26 2002] [notice] Apache/2.0.28 (Unix) mod_ssl/3.0a0 
OpenSSL/0.9.6 DAV/2 configured -- resuming normal operations
[Wed Feb 27 19:44:39 2002] [notice] child pid 645 exit signal Segmentation 
fault (11)
[Wed Feb 27 19:45:31 2002] [notice] child pid 646 exit signal Segmentation 
fault (11)
 [2002-03-07 17:04 UTC] sukhruprai at yahoo dot com
This time I compiled php with --enable-debug option to generate backtrace.A
new file cgisock (0 size) is automatically created after this compile. I think
problem is related to swf functions(swf.c). gdb results are at the end:

-----------------------------------APACHE 2-------------------------------
./configure --prefix=/wwwroot --enable-auth-anon --enable-auth-db 
--enable-auth-dbm --enable-auth-digest --enable-file-cache --enable-echo 
--enable-cache --enable-mem-cache --enable-example --enable-ext-filter 
--enable-case-filter --enable-case-filter-in --enable-mime-magic 
--enable-cern-meta --enable-expires --enable-usertrack --enable-unique-id 
--enable-ssl --enable-optional-hook-export --enable-optional-hook-import 
--enable-optional-fn-import --enable-optional-fn-export --enable-http 
--enable-dav --enable-cgi --enable-info --enable-cgid --enable-dav-fs 
--enable-vhost-alias --enable-speling --enable-actions --enable-rewrite 
--enable-so

--------------------------------------PHP 4.1.1--------------------------
./configure --prefix=/wwwroot/php --with-apxs2=/wwwroot/bin/apxs 
--with-mod_charset --with-config-file-path=/wwwroot/php/ --with-openssl 
--with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-cpdflib 
--with-png-dir --with-jpeg-dir --with-tiff-dir --enable-ctype --with-curl 
--with-db3 --with-dom --enable-exif --enable-filepro --enable-ftp 
--with-gd --enable-gd-native-ttf --with-xpm-dir --with-freetype-dir=/usr 
--with-ttf --with-t1lib --with-gettext --with-gmp --with-hyperwave 
--with-iconv --with-imap --with-kerberos --with-imap-ssl --with-ircg 
--with-ldap --enable-mbstring --enable-mbstr-enc-trans 
--with-mcal=/usr/src/libmcal --with-mhash 
--with-mnogosearch=/usr/local/mnogosearch --with-mysql --with-pgsql 
--with-pspell --with-qtdom --enable-trans-sid --enable-shmop --with-snmp 
-enable-ucd-snmp-hack --enable-sockets --with-regex=php --with-swf 
--enable-wddx --with-expat-dir=/usr/local --enable-xslt --with-xslt-sablot 
--with-yaz=/usr/local/lib --enable-yp --with-zip --with-pdflib 
--enable-versioning --with-tsrm-st --with-tsrm-pthreads 
--enable-track-vars --enable-overload --with-mcrypt 
--with-java=/usr/java/j2sdk1.4.0 --enable-sysvsem --enable-sysvshm 
--enable-debug


After making and installing both apache and php when I started apache and 
tried to access http://localhost. It worked and apache test page was
displayed.
Then I tried to access a php file with only phpinfo() function. Netscape displayed a message the document contained no date. Follwing was added to apache error_log:

-------------------------------------------------------------------------------
[Fri Mar 08 02:12:54 2002] [notice] Digest: generating secret for digest authentication ...
[Fri Mar 08 02:12:54 2002] [notice] Digest: done
[Fri Mar 08 02:12:55 2002] [notice] Apache/2.0.28 (Unix) mod_ssl/3.0a0 OpenSSL/0.9.6 DAV/2 configured -- resuming normal operations
[Fri Mar 08 02:13:16 2002] [error] Optional hook test said: GET / HTTP/1.0
[Fri Mar 08 02:13:16 2002] [error] Optional function test said: GET / HTTP/1.0
[Fri Mar 08 02:13:16 2002] [error] Optional hook test said: GET /apache_pb.gif HTTP/1.0
[Fri Mar 08 02:13:16 2002] [error] Optional function test said: GET /apache_pb.gif HTTP/1.0
[Fri Mar 08 02:14:47 2002] [notice] child pid 4472 exit signal Segmentation fault (11)
--------------------------------------------------------------------

I stoped apache removed all logs files and tried /wwwroot/bin/httpd -X 
after running 'ulimit -c unlimited' and 
then accessed a php file with phpinfo() and lynx displayed unable to 
access start document...unkonwn network error and exited. 
/wwwroot/bin/httpd -X produced:

Segmentation fault

and exited.

No core file is produced under /wwwroot/bin (/wwwroot is apache 2.0 
install directory). /wwwroot/bin has write permission for everyone. Then I
tried the second option like this and was successful:

-------------------------------------------

gdb /wwwroot/bin/httpd
GNU gdb 5.0rh-5 Red Hat Linux 7.1
Copyright 2001 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-redhat-linux"...
(gdb) run -X
Starting program: /wwwroot/bin/httpd -X
[New Thread 1024 (LWP 763)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 763)]
0x405e52c1 in zm_activate_swf (type=1, module_number=8, tsrm_ls=0x81e7210)
    at swf.c:173
173             SWFG(use_file) = 0;

(gdb) bt
#0  0x405e52c1 in zm_activate_swf (type=1, module_number=8, tsrm_ls=0x81e7210)
    at swf.c:173
#1  0x404b08f1 in module_registry_request_startup (module=0x81f7c00, 
    tsrm_ls=0x81e7210) at zend_API.c:1145
#2  0x404b2b3d in zend_hash_apply (ht=0x407dee40, 
    apply_func=0x404b08c8 <module_registry_request_startup>, tsrm_ls=0x81e7210)
    at zend_hash.c:669
#3  0x404ad2fe in zend_activate_modules (tsrm_ls=0x81e7210) at zend.c:577
#4  0x404ba9e0 in php_request_startup (tsrm_ls=0x81e7210) at main.c:684
#5  0x404b8fd7 in php_apache_request_ctor (f=0x819c244, ctx=0x8190d7c, 
    tsrm_ls=0x81e7210) at sapi_apache2.c:290
#6  0x404b90ff in php_output_filter (f=0x819c244, bb=0x819c3bc)
    at sapi_apache2.c:326
#7  0x080c12bc in ap_pass_brigade (next=0x819c244, bb=0x819c3bc)
    at util_filter.c:276
#8  0x080c7659 in default_handler (r=0x81872c4) at core.c:2785
#9  0x080b67b4 in ap_run_handler (r=0x81872c4) at config.c:185
#10 0x080b6cf6 in ap_invoke_handler (r=0x81872c4) at config.c:344
#11 0x0808c2ce in ap_process_request (r=0x81872c4) at http_request.c:286
#12 0x0808853e in ap_process_http_connection (c=0x8182f44) at http_core.c:289
#13 0x080bf9f0 in ap_run_process_connection (c=0x8182f44) at connection.c:82
#14 0x080bfb85 in ap_process_connection (c=0x8182f44) at connection.c:219
#15 0x080b5390 in child_main (child_num_arg=0) at prefork.c:803
---Type <return> to continue, or q <return> to quit--
#16 0x080b5441 in make_child (s=0x8105994, slot=0) at prefork.c:839
#17 0x080b5553 in startup_children (number_to_start=5) at prefork.c:913
#18 0x080b5997 in ap_mpm_run (_pconf=0x81031ec, plog=0x814b42c, s=0x8105994)
    at prefork.c:1129
#19 0x080baac8 in main (argc=2, argv=0xbffffa14) at main.c:432
#20 0x402dfe5e in __libc_start_main (main=0x80ba588 <main>, argc=2, 
    ubp_av=0xbffffa14, init=0x8063240 <_init>, fini=0x80d1950 <_fini>, 
    rtld_fini=0x4000d3c4 <_dl_fini>, stack_end=0xbffffa0c)
    at ../sysdeps/generic/libc-start.c:129


(gdb)
 [2002-03-07 18:00 UTC] mfischer@php.net
Hmm .. have you compiled php with thread support?

It seems the swf module is missing an ZEND_INIT_MODULE_GLOBALS() call in PHP_MINIT_FUNCTION().

Can you test this patch (against current CVS) ?

diff -u -r1.44 swf.c
--- swf.c       11 Dec 2001 15:30:38 -0000      1.44
+++ swf.c       7 Mar 2002 22:59:37 -0000
@@ -138,10 +138,19 @@
 }
 /* }}} */
 
+/* {{{ php_swf_init_globals
+ */
+static void php_swf_init_globals(zend_swf_globals *swf_globals) {
+       swf_globals->use_file = 0;
+       swf_globals->tmpfile_name = NULL;
+}
+
 /* {{{ PHP_MINIT_FUNCTION
  */
 PHP_MINIT_FUNCTION(swf)
 {
+       ZEND_INIT_MODULE_GLOBALS(swf, php_swf_init_globals, NULL);
+
        REGISTER_LONG_CONSTANT("MOD_COLOR", MOD_COLOR, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("MOD_MATRIX", MOD_MATRIX, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("TYPE_PUSHBUTTON", TYPE_PUSHBUTTON, CONST_CS | CONST_PERSISTENT);
 [2002-03-08 14:46 UTC] sukhruprai at yahoo dot com
I don't know much about cvs and how diff works. So I couldn't make anything out of these lines. One thing I did was, removed --with-swf from configure option and everything worked fine. I want to help but I have a very slow pentium-1 computer and a slow dial up connection (in punjab-IN) so it takes at least one hour to compile php alone. I know little C so if you tell me what to add, what to remove and where then I can make that change and try to compile again and see if that works.
 [2002-04-19 11:41 UTC] aaron@php.net
Please try again with Apache 2.0.35 (GA) and PHP from
CVS (either the 4.2.0 branch or HEAD).
 [2002-04-25 18:27 UTC] jwoolley@php.net
This has been hiding as feedback under Apache2, but it's 
most likely not Apache2 related, and I didn't want this 
patch, if valid, to be forgotten.  So I'm reopening and 
reclassifying as SWF related. 
Thanks... 
 [2002-05-11 11:59 UTC] sterling@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/. 
Thank you for the report.


 [2002-11-11 09:43 UTC] ssruprai at hotmail dot com
I used php 4.2.3 and apache 2.0.43 this time and swf extension is still causing segmentation fault.

PHP Configure
--------------
./configure --with-config-file-path=/wwwroot/php --with-apxs2=/wwwroot/bin/apxs --prefix=/wwwroot/php --enable-trans-sid --with-java --with-swf --enable-debug


Here is gdb output when a file with phpinfo() is accessed:

[root@sukhwinder php-4.2.3]# gdb /wwwroot/bin/httpd
GNU gdb 5.0rh-5 Red Hat Linux 7.1
Copyright 2001 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-redhat-linux"...
(gdb) run -X
Starting program: /wwwroot/bin/httpd -X
[New Thread 1024 (LWP 9038)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 9038)]
0x40454bf9 in zm_activate_swf (type=1, module_number=2, tsrm_ls=0x8100f60)
    at swf.c:173
173             SWFG(use_file) = 0;
(gdb)
 [2002-11-11 09:48 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-11-21 17:08 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 30 22:01:28 2024 UTC