Jump to content

PHP infinite loops


negative_creep

Recommended Posts

Hi!

 

We have a SLES 10 web server with Apache 2.2.0 and PHP 5.1.2. The server hosts around 50 web sites (virtual hosts). I've noticed a strange problem. One of our clients apparently has an infinite loop in PHP code. It causes new apache processes to be opened, and they never exit. When the number of processes hits the limit... the apache hangs, and 50 websites are down.

 

I've tried to lower max_execution_time in php.ini with no success. The error_log states "PHP Fatal Error: Maximum execution time of 10 seconds exceeded", but the process keeps on and never ends.

 

I've also experimented with infinite loops and here is a code that can replicate the problem:

 

<?php

  echo "<html><body>Starting...<br/>\n";

  for($i = 0; $i > -1; $i++)

  {

    echo "$i ";

    flush();

  }

  echo "End.</body></html>\n";

?>

 

The runaway processes clearly show on server-status page (apache module status with ExtendedInfo on). The process still shows there even after i close the browser that called the infinite PHP file!

 

Does anyone have any idea how to prevent PHP/Apache runaway processes?

 

Thanks in advance.

 

Vladimir.

 

Link to comment
https://forums.phpfreaks.com/topic/143641-php-infinite-loops/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.