Re: *crash* on try to find out how many nestinglevelsare allowed

From: Date: Sun, 09 Jul 2000 19:41:47 +0000
Subject: Re: *crash* on try to find out how many nestinglevelsare allowed
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-23950@lists.php.net to get a copy of this message
Hello Andi, On 09-Jul-00 12:48:32, you wrote: >Your attitude is also incorrect. It can only be fixed, as far as I know, by >adding code which will limited the amount of recursive function calls. This >will not only slow down PHP but it will also pose the question of where the >limit is. Not all systems have the same stack size or each up the stack at >the same rate. >In my opinion, we are better off leaving it the way it is for now although >for multi-threaded servers we might want to enable the *slow* approach. >Anyway, maybe the best is not to write infinite recursion? I'm afraid you are missing the point. Nobody writes useful scripts that go on infinite recursion on purpose. So, if scripts go on infinite recursion that was a programmer's mistake. The problem with PHP is that it crashes without giving any clue to the programmer that it crashed because a script went infinite recursion. Although the crash was caused by a programmer's mistake, PHP could help by having some control on to how deep functions can call themselves directly or indirectly. I don't think the checks should be made against the current process CPU stack pointer address but rather have a configuration option that tells how many nested calls a function is allowed to make to itself directly on indirectly. When the number of calls is exceeded the script simply exits with a runtime error saying something like "the limit of recursive calls to function xyz() was exceeded". As for the overhead of this it could be eliminated by having some option to tell whether to make or not recursion checks. If recursion checks are off, I believe that the overhead is just of checking that variable in all functions which I think it is neglectable. The point of all this for you is that you avoid bogus PHP crash bug reports that are due to infinite recursion. Regards, Manuel Lemos Web Programming Components using PHP Classes. Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org -- E-mail: mlemos@acm.org URL: http://www.mlemos.e-na.net/ PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp --

« previous php.dev (#23950) next »