PHP script crashes standard DA server by endless running apache process

Christophe1

Verified User
Joined
Aug 24, 2008
Messages
48
Location
Belgium
When trying to open a non-existing folder in php, the apache process uses about 90% of the cpu and the longer the process runs, the more memory it uses.
Such a process keeps running until closed manually or the server crashes. Memory limitations and timeouts that are set in php, doesn't seem to do anything.

It's a standard DA server with Apache 2.2.27, php 5.3.28 and suPHP 0.7.1.

Before updating to these versions of Apache and PHP, the same scripts were being ended after a while so the extra load was only temporarily and the server didn't crash.

Any suggestions? A known bug?


PS: I know it's a bad php script, but the point is that such bad scripts from customers can crash a server...
 
Use CSF to limit the execute time of a script or limit the amount of workers in your httpd-mpm.conf.
 
Thank you for this suggestion, but a little more info to show the actual problem:


Code exemple:

<?php

$dir = "not-existing-folder";

$dh = opendir($dir);
while (false !== ($filename = readdir($dh)))
{
$files[] = $filename;
}

?>

In the process list, a process that runs under the user of the hosting account pops up as expected, and here I also see which script is causing problems (let's call this process 1). In addition to the 1st process, it is another process running under user Apache that is responsible for the high load (let's call this process 2).

Normally, after a while, process 1 is stopped by the restrictions set in php.ini, and process 2 normalizes.

This script is used for years and never caused problems.

Since I've updated to Apache 2.2.27 (and simultaneously php to 5.3.28), process 1 is not stopped by the limitations set in php.ini, so process 2 keeps running until the server crashes.
 
Back
Top