php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36455 php_apache_shutdown_wrapper calls itself until segfault
Submitted: 2006-02-19 20:54 UTC Modified: 2006-02-22 19:12 UTC
From: haleden at colorado dot edu Assigned:
Status: Not a bug Package: Apache related
PHP Version: 5.1.2 OS: redhat 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: haleden at colorado dot edu
New email:
PHP Version: OS:

 

 [2006-02-19 20:54 UTC] haleden at colorado dot edu
Description:
------------
there are a bunch of reports out there that have been 
labeled "bogus" that i bet were not.

i began to have problems starting apache 1.3.27 reliably 
after installing the php module.

i found that if i commented out the php module, apache would 
start. then, if i went in and uncommented the php module, 
and did a apachectl restart, things were fine.

i finally got some time to dig deeper, and ran it under gdb 
and found that it was crashing in a deep stack of nested 
calls to php_apache_shutdown_wrapper.

looking at the source, i see that 
php_apache_shutdown_wrapper calls 
apache_sapi_module.shutdown which is defined to be 
php_apache_shutdown_wrapper. i suspect that at one time 
apache_sapi_module.shutdown pointed to 
php_apache_request_shutdown and things worked until someone 
decided that the wrapper should be called but forgot to 
change the wrapper to call php_apache_request_shutdown.

as to why it was happening at startup, i conjecture that 
apache keeps track of modules in some way and if a module 
didn't shutdown cleanly before, it calls the shutdown hook 
to clean up before starting again. by starting it without 
the module, that check was cleared, and it would not run the 
shutdown hook the next time.

i'm not an expert at all of this stuff, but i made the 
change to the wrapper and it seems to work--further testing 
and sanity checking advised.

thanks,

hal


Reproduce code:
---------------
see above description for apache config changes

Expected result:
----------------
apache starts sucessfully each time when php module defined

Actual result:
--------------
apache doesn't always start successfully when php module 
defined

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-19 21:03 UTC] haleden at colorado dot edu
oops, forgot to say that the changes go in:

sapi/apache/mod_php5.c

...
int php_apache_shutdown_wrapper(void)
{
    apache_php_initialized = 0;
    /*  apache_sapi_module.shutdown(&apache_sapi_module);*/
    php_apache_request_shutdown(&apache_sapi_module);
...
 [2006-02-22 08:46 UTC] tony2001@php.net
Works perfectly fine for me and N millions of PHP users.
Apache 1.3.27 is very old, try to upgrade it first.
And decribe in details what exactly did you do to reproduce it.
 [2006-02-22 17:53 UTC] haleden at colorado dot edu
maybe they never stop their server or later version of 
apache don't properly call shutdown--i don't know. 

i don't need to upgrade my server because fixing the obvious 
bug gets rid of the problem. (in what universe is it okay to 
have an unchecked recursive call to yourself and expect 
reasonable behavior?)

to reproduce the problem:

apachectl stop
apachectl start
ps -auxwww|grep httpd --> no httpd processes
httpd -X
(segment violation, core dumped)

gdb httpd core
...
where
php_apache_shutdown_wrapper()
php_apache_shutdown_wrapper()
php_apache_shutdown_wrapper()
php_apache_shutdown_wrapper()
php_apache_shutdown_wrapper()
php_apache_shutdown_wrapper()
php_apache_shutdown_wrapper()
...
 [2006-02-22 18:45 UTC] tony2001@php.net
>in what universe is it okay to have an unchecked recursive
> call to yourself and expect reasonable behavior?

In my universe this problem is not reproducible with any Apache & PHP version I have.
Since you don't want to try to upgrade Apache -> bogus.
 [2006-02-22 18:59 UTC] haleden at colorado dot edu
calling something bogus just because i won't upgrade a 
productions server that i do not have the rights to upgrade 
seems to be a very limiting approach.

look at the code!
 [2006-02-22 19:12 UTC] tony2001@php.net
Since I am (and everyone else is) unable to reproduce it, we need additional information for you, which you don't want to provide. So yes, bogus. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 13:01:29 2024 UTC