From:
Operating system: Linux
PHP version: Irrelevant
Package: Apache2 related
Bug Type: Bug
Bug description:php module not loaded when php module is enabled and then
restarted
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
--
Edit bug report at http://bugs.php.net/bug.php?id=52218&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52218&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52218&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52218&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52218&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52218&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52218&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52218&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52218&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52218&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52218&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52218&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52218&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52218&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52218&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52218&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52218&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52218&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52218&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52218&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52218&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52218&r=mysqlcfg