note 66799 deleted from language.exceptions by bjori

From: Date: Mon, 29 May 2006 21:34:27 +0000
Subject: note 66799 deleted from language.exceptions by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-112511@lists.php.net to get a copy of this message
Note Submitter: nitrous at fuckoff dot com Reason: useless ---- Infinite recursion: There are limits with recursion when using functions. I can only seem to achieve 48,000 levels before segfault. When I implement recursion with Exceptions (a gross hack), I have an unlimited call stack (limited by RAM). If you modify the included code to pass parameters, you can perform extremely deep recursive function calls. This code block demonstrates the uncapped limits in PHP and the ability to wreck your machine using this method. Be careful! A static reference count in the constructor and destructor is advised to limit the recursion depth manually. class Eggception extends Exception { public function __construct($ex) { parent::__construct($ex); try { throw new EggceptionSubclass('Do math here'); } 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) // without proper process limits, potentially crashing the // entire machine. throw new Eggception('Do my func');

« previous php.notes (#112511) next »