ID: 37204 Comment by: judas dot iscariote at gmail dot com Reported By: mailslot at mac dot com Status: Open Bug Type: Reproducible crash Operating System: Linux 2.4.21-9.EL PHP Version: 5.1.2 New Comment:
the recursion Limit problem is well known (for years), and there is no solution at this time.( because solution should be adecuate for any legitimate use, not just for average use) Use Xdebug to set a recursion limit in your dev enviroment. Previous Comments: ------------------------------------------------------------------------ [2006-04-26 00:45:04] mailslot at mac dot com Description: ------------ I encountered this problem while debugging an exception logging class. Infinite recursion problems are a coding mistake, but I've never seen one take down Apache before. Apache will grow in size until virtual memory starts swapping. The CPU will be at 100% and eventually, appears to halt. Limits, obviously, are not being used... yet. Reproduce code: --------------- <?php class Eggception extends Exception { public function __construct($ex) { parent::__construct($ex); try { // let's say that a database object throws derived Eggception throw new EggceptionSubclass('It happens'); // this is valid (not infinitely recursive) //throw new Exception('It happens'); } catch (Exception $e) { // should swallow exception, right? // not before a never-ending recursive bomb } } } class EggceptionSubclass extends Eggception {} // the following causes a runaway process (memory leak & // CPU spike) with Apache 2.0.55 and PHP 5.1.2 // rather quickly, all server resources become exhausted // without proper process limits, potentially crashing the // entire machine. throw new Eggception('Exception Bomb'); ?> Expected result: ---------------- A timeout after a large CPU spike... perhaps a stack overflow error. An exception recursion counter that kills a script whenever it's 1,000 layers deep in an exception stack... that would be great. Actual result: -------------- The process (PHP or Apache, depending on which are used to execute the script) will consume as much memory allowed while pegging the CPU at 100% utilization. Kill -9 works fine. Workarounds include ulimit and softlimit. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37204&edit=1