PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #14303 httpd threads hang with large data structures
Submitted:30 Nov 2001 1:39pm UTC Modified: 2 Jan 2002 10:39am UTC
From:Darren dot Gamble at sjrb dot ca Assigned to:
Status:Closed Category:Reproducible crash
Version:4.0.6 OS:Redhat 7.2
View/Vote Developer Edit Submission

Welcome! If you don't have a SVN 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.
SVN Username: SVN Password:
Quick Fix:
Status: Assign to:
Category:
Summary:
From: Darren dot Gamble at sjrb dot ca
New email:
Version: OS:
New/Additional Comment:

[30 Nov 2001 1:39pm UTC] Darren dot Gamble at sjrb dot ca
I've had a lot of problems recently with PHP cleaning up properly after
using large data structures.

A sample script is included:

$huge_array = array();
for ( $i=0 ; $i<= 8000 ; $i++ ) {
  foreach (array("cn" , "uid" , "sn" , "givenName" , "attr1" , "attr2" ,
"attr3") as $j ) {
    for ( $k=0 ; $k<= 50 ; $k++ ) { 
      $huge_array[$i][$j][$k] = rand(0,10000)."value";
    }
  }
}

The script executes normally, but the httpd thread remains afterwards,
consuming memory and CPU.  It appears to need a kill -9 to make it
finally die.  If enough of these are run, all of the child processes of
apache get tied up, preventing it from serving any more requests.  At
this point the threads have to be killed and the server restarted.

I've also encountered similar problems with storing the results of a
large ldap_get_entries(), although the behavior of the above script
suggests that the problem is not actually with the LDAP function. 
Reducing the size of the query incrementally reveals that there seems to
be a "breaking point" where this behavior begins.

httpd also logs that it has problems terminating its child processes:

[warn] child process 9541 still did not exit, sending a SIGTERM

I'm running php-4.0.6-7 under apache-1.3.20-16, all Redhat 7.2 RPMs,
with the default configuration.
[2 Dec 2001 12:03am UTC] zak@php.net
There is a not-yet-documented function called 
apache_child_terminate that should help you.

Call the function at the end of your script so that Apache 
knows to terminate the process running the script (and 
clean up its memory)

There was a recent thread on the PHP Dev mailing list 
related to this issue. If you are curious, check the list 
archives (or news group) for more information.  The first 
message in the thread was started by Edin Kadribasic on 
Fri, 23 Nov 2001. You can also search for 
ap_child_terminate and apache_child_terminate.

Visit http://www.php.net/support.php for information on 
where to find the archive and news group.

Also, please do write back to let us know if the function 
helped your problem.
[23 Dec 2001 4:52am UTC] lobbin@php.net
No feedback. Closing.
[2 Jan 2002 10:39am UTC] Darren dot Gamble at sjrb dot ca
Good day,

Sorry for the lack of reply.

The function you had requested that I try, "apache_child_terminate", is
not enabled.  Looking at the source, it appears that this was toggled at
compile time.

Regardless of the usefulness of this function, I don't feel that the
ticket should be closed until the problem itself is actually dealt with,
instead of using this very patch-y workaround.

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC