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

From: Date: Sun, 09 Jul 2000 16:15:47 +0000
Subject: Re: *crash* on try to find out how many nestinglevelsare allowed
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-23924@lists.php.net to get a copy of this message
Andi Gutmans wrote: > > At 10:41 09/07/00 -0400, Shane Caraveo wrote: > > >Stanislav Malyshev wrote: > > > > > > w>> I wanted to find out how many nesting levels are allowed, but after > > > w>> class "a" gets instanciated from inside of "b", PHP > > > w>> crashes, that > > should > > > w>> not be. > > > > > > And what did you expect? You tried to crash it, you succeeded. Infinite > > > recursion leads to crash. Try it in C, you get the same. > > > >That's an entirely lame attitude. The goal here should be a stable php, > >irregardless of the quality of code php is running. In the case of > >infinite loops, recursions, etc., php can either throw an error if it is > >somehow recognizable, or it can simply timeout. Allowing it to crash > >because 'infinite recursion leads to crash' is pathetic. If it crashes, > >it can be fixed. > > Shane, > > Your attitude is also incorrect. My attitude is fix the crash rather than to say 'dont do it and it wont crash'. I don't think my attitude is wrong, but maybe it is not possible to deal with such a crash effectivly. > 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? > > Andi I agree that writing infinite recursion is not a good thing and should not be done. I disagree that it should crash php. Sometimes bugs (in scripts, certainly not in php itself ;-) just happen, possibly even infinite recursion. On my server, there are several people who write scripts, not all being real programmers, I can see stuff happening that could lead to a crash, which could take down all the sites on the server. If it's possible to prevent such a crash, that is an option I would want. Do you have any remote idea of how much it would slow down php? You and Zeev added a lot of performance to php, I would rather sacrifice some of that new speed for stability. I may be wrong as I know next to nothing about parsers, but I would think it should be possible to check the remaining stack size and throw a stack overflow error (if that happens), rather than crashing. Doing it this way would also do away with any need to count the number of recursions (and have some limit on that). Shane

« previous php.dev (#23924) next »