php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52218 php module not loaded when php module is enabled and then restarted
Submitted: 2010-07-01 12:10 UTC Modified: 2010-07-01 16:38 UTC
From: php at spam dot wizbit dot be Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 5.3.3-RC1 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at spam dot wizbit dot be
New email:
PHP Version: OS:

 

 [2010-07-01 12:10 UTC] php at spam dot wizbit dot be
Description:
------------
When apache is restarted after enabling php then it does not load PHP.
When apache is restarted again then it does load PHP.

I first noticed this with (stock) php-4.4.9 and apache 2.2.15 where it resulted in segmentation faults on every request.
I then tested this with php-5.2.6 that comes with debian (PHP/5.2.6-1+lenny8 with Suhosin-Patch) and it shows the same problem but does not segfault.


Steps to reproduce (on debian):
1. install apache2 and php
2. stop apache: apache2ctl -k stop
3. disable the php module: rm /etc/apache2/mods-enabled/php.*
4. start apache: apache2ctl -k start
5. enable the php module: ln -s /etc/apache2/mods-available/php.* /etc/apache2/mods-enabled/
6. restart apache: apache2ctl -k restart
7. Check the log file => PHP not loaded. (on php-4.4.9 every request from this moment on caused a segmentation fault)
8. restart apache again: apache2ctl -k restart
9. Check the log file => PHP is loaded

NOTE: do not use the debian init script (/etc/init.d/apache2). 



I do not know what the severity of this issue should be.
It does not appear to be segfaulting in recent versions but that does not nessesarly mean that the segfault is fixed (it could be hiding somewhere - I did not try very hard to get it to segfault).



The logfile/traces/a guess where the problem is:

An example log file:

PHP disabled: apache2ctl -k start:
  [Thu Jul 01 10:55:03 2010] [notice] Apache/2.2.9 (Debian) configured -- resuming normal operations

PHP enabled; apache2ctl -k restart:
  [Thu Jul 01 10:55:10 2010] [notice] SIGHUP received.  Attempting to restart
  [Thu Jul 01 10:55:10 2010] [notice] Apache/2.2.9 (Debian) configured -- resuming normal operations
==> PHP not loaded

Another restart: apache2ctl -k restart:
  [Thu Jul 01 10:55:15 2010] [notice] SIGHUP received.  Attempting to restart
  [Thu Jul 01 10:55:15 2010] [notice] Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch configured -- resuming normal operations
==> PHP now loaded



debugging this with php 4.4.9 may points to a problem in sapi/apache2handler/sapi_apache2.c: php_apache_server_startup.
(I did not debug this with php 5 but I did check the code in trunk and it looks the same).

The start of the code:
	static int
	php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
	{
	        void *data = NULL;
	        const char *userdata_key = "apache2hook_post_config";
	
	        /* Apache will load, unload and then reload a DSO module. This
	         * prevents us from starting PHP until the second load. */


The comment makes me believe that it is the expectation that php_apache_server_startup is called twice but that does not appear to be the case.

gdb session:

Breakpoint 1 (php_apache_server_startup) pending.
(gdb) c
Continuing.

Program received signal SIGHUP, Hangup.
0xb7c2cfb8 in select () from /ub/lib/libc.so.6
(gdb) c
Continuing.

Program received signal SIGHUP, Hangup.
0xb7b9df51 in kill () from /ub/lib/libc.so.6

# NOTE: this is the first restart after enabling the module
(gdb) c
Continuing.
Breakpoint 2 at 0xb78de20f: file /root/work/php-4.4.9/sapi/apache2handler/sapi_apache2.c, line 367.
Pending breakpoint "php_apache_server_startup" resolved

Breakpoint 2, php_apache_server_startup (pconf=0x80e80a8, plog=0x81301c8, ptemp=0x80f20d0, s=0x80ed0c0) at /root/work/php-4.4.9/sapi/apache2handler/sapi_apache2.c:367
367		void *data = NULL;
(gdb) n
368		const char *userdata_key = "apache2hook_post_config";
(gdb) n
372		apr_pool_userdata_get(&data, userdata_key, s->process->pool);
(gdb) n
373		if (data == NULL) {
(gdb) p data
$1 = (void *) 0x0
(gdb) c
Continuing.

# NOTE: PHP is not loaded in apache even tho it is enabled

Program received signal SIGHUP, Hangup.
0xb7c2cfb8 in select () from /ub/lib/libc.so.6
(gdb) c
Continuing.

Program received signal SIGHUP, Hangup.
0xb7b9df51 in kill () from /ub/lib/libc.so.6
(gdb) c
Continuing.
# NOTE: this is the second restart after enabling the module


warning: Temporarily disabling breakpoints for unloaded shared library "/ub/pkg/httpd/modules/libphp4.so"

Breakpoint 2, php_apache_server_startup (pconf=0x80e80a8, plog=0x81301c8, ptemp=0x81361e0, s=0x80ed0c0) at /root/work/php-4.4.9/sapi/apache2handler/sapi_apache2.c:367
367		void *data = NULL;
(gdb) n
368		const char *userdata_key = "apache2hook_post_config";
(gdb) n
372		apr_pool_userdata_get(&data, userdata_key, s->process->pool);
(gdb) n
373		if (data == NULL) {
(gdb) p data
$2 = (void *) 0x1
(gdb) n
384		if (apache2_php_ini_path_override) {
(gdb) c
Continuing.

# NOTE: PHP is now loaded in apache




For reference a backtrace of the segfault that happens on php-4.4.9: (php compiled with debugging, apache compiled without debugging)
(gdb) bt full
#0  0xb7835351 in _zend_is_inconsistent (ht=0x0, file=0xb7a22cc8 "/root/work/php-4.4.9/Zend/zend_hash.c", line=722) at /root/work/php-4.4.9/Zend/zend_hash.c:94
No locals.
#1  0xb7837061 in zend_hash_apply_with_argument (ht=0x0, apply_func=0xb783d099 <zend_restore_ini_entry_cb>, argument=0x8) at /root/work/php-4.4.9/Zend/zend_hash.c:722
	p = (Bucket *) 0x20
#2  0xb783d28d in zend_ini_deactivate () at /root/work/php-4.4.9/Zend/zend_ini.c:101
No locals.
#3  0xb784b5ac in php_apache_ini_dtor (r=0x81a0b30, p=0x0) at /root/work/php-4.4.9/sapi/apache2handler/sapi_apache2.c:449
	orig_bailout = {{__jmpbuf = {0, 0, 0, 0, 0, 0}, __mask_was_saved = 0, __saved_mask = {__val = {0 <repeats 32 times>}}}}
	orig_bailout_set = 0 '\0'
#4  0xb784b78e in php_handler (r=0x81a0b30) at /root/work/php-4.4.9/sapi/apache2handler/sapi_apache2.c:492
	ctx = (php_struct *) 0x0
	conf = (void *) 0x8135b78
	brigade = (apr_bucket_brigade *) 0x0
	bucket = (apr_bucket *) 0x0
	rv = 0
	parent_req = (request_rec *) 0x0
#5  0x08073ef8 in ap_run_handler ()
No symbol table info available.
#6  0x08076aae in ap_invoke_handler ()
No symbol table info available.
#7  0x08093b8d in ap_process_request ()
No symbol table info available.
#8  0x08091299 in ?? ()
No symbol table info available.
#9  0x081a0b30 in ?? ()
No symbol table info available.
#10 0x00000004 in ?? ()
No symbol table info available.
#11 0x081a0b30 in ?? ()
No symbol table info available.
#12 0x00000005 in ?? ()
No symbol table info available.
#13 0x0819a9b0 in ?? ()
No symbol table info available.
#14 0x0819a818 in ?? ()
No symbol table info available.
#15 0x081837f8 in ?? ()
No symbol table info available.
#16 0x00000000 in ?? ()
No symbol table info available.



Expected result:
----------------
PHP loaded the first time apache is restarted

Actual result:
--------------
PHP not loaded the first time apache is restarted

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-01 16:03 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-07-01 16:03 UTC] johannes@php.net
Both 4.4.9 and 5.2.6 are old. If there is an issue with the Debian builds please talk to them.
 [2010-07-01 16:38 UTC] php at spam dot wizbit dot be
-PHP Version: Irrelevant +PHP Version: 5.3.3-RC1
 [2010-07-01 16:39 UTC] php at spam dot wizbit dot be
Since you insisted: Retested with 5.3.3-RC1. (even tho I checked the code in trunk and said it was the same.)

No surprise: the same problem exist.

First start with php disabled:
Thu Jul 01 18:02:07 2010] [notice] Digest: generating secret for digest authentication ...
[Thu Jul 01 18:02:07 2010] [notice] Digest: done
[Thu Jul 01 18:02:07 2010] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations


First restart with php enabled:
[Thu Jul 01 18:02:13 2010] [notice] SIGHUP received.  Attempting to restart
[Thu Jul 01 18:02:13 2010] [notice] Digest: generating secret for digest authentication ...
[Thu Jul 01 18:02:13 2010] [notice] Digest: done
[Thu Jul 01 18:02:13 2010] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations

=> PHP not loaded but it is enabled in the code

Second restart with PHP enabled:

[Thu Jul 01 18:02:15 2010] [notice] SIGHUP received.  Attempting to restart
[Thu Jul 01 18:02:16 2010] [notice] Digest: generating secret for digest authentication ...
[Thu Jul 01 18:02:16 2010] [notice] Digest: done
[Thu Jul 01 18:02:16 2010] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3-RC1 configured -- resuming normal operations


=> PHP now loaded.


Note that this never was a problem debian builds. I said I experienced this first with a stock php-4.4.9 and that I then tested with debian since that was easier then compiling a stock 5.3.3 build.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 11:01:30 2024 UTC