Re: PHP 4.0 Bug #9136 Updated: simple script with infinite function calls causes seg fault

From: Date: Wed, 07 Feb 2001 02:31:07 +0000
Subject: Re: PHP 4.0 Bug #9136 Updated: simple script with infinite function calls causes seg fault
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-45916@lists.php.net to get a copy of this message
hi, indeed it is theoretically impossible to track this :) implement a recursive alrorithm for something e.g.: function foo($n) { // calc $n! if ($n<=1) return $n; else return foo($n-1)*$n; } now tell me if it is infinite or finite? ;-) this is a verification and cannot be solved runtime. the best thing that can be done is to set a stack limit (php function call level) to something reasonable and thus avoid the segfault. b. ----- Original Message ----- From: <waldschrott@php.net> To: <php-dev@lists.php.net> Sent: Wednesday, February 07, 2001 12:31 AM Subject: [PHP-DEV] PHP 4.0 Bug #9136 Updated: simple script with infinite function calls causes seg fault > ID: 9136 > Updated by: waldschrott > Reported By: nathan@synop.com > Status: Closed > Bug Type: Reproduceable crash > Assigned To: waldschrott > Comments: > > and guess this "bug" was present in any version before, what > do you expect to happen here? you will never leave these > function calls (as you know I guess), as far as your stack > is full it is full > > remember php has to remember each and every function call it > did... > > a() > b() > a() > b() > .... > > if you really need exactly this construct, I would suggest > you to use a static variable to count the total function > calls and find the critical values a specific system > segfaults (with your original code), then you stick a > for(;;) around it and implement a check (eg. in a()) against > the static variable to leave the recursion if a value with > enough distance to the critical value is reached, then you > should be able to begin the recursion again > > any recursion can be displayed as a loop, do not use > recursion if you want to recurse infinitely > > Previous Comments: > -------------------------------------------------------------------------- - > > [2001-02-06 17:22:36] derick@php.net > PHP doesn't handle infinite recursion, and as earlier was discussed on the php-dev list, it wont be implemented to guard for this, because of the high performance impact. > > -------------------------------------------------------------------------- - > > [2001-02-06 17:18:03] nathan@synop.com > ------------------- > <% > > function a () { > b(); > } > > function b () { > a(); > } > > a(); > > %> > > <h1>done</h1> > --------------------- > > The simple script above causes a seg fault. If you need more info on configuration etc please mail me. We made this simple example from a more compilcated instance. This bug was also present in 4.0.3pl1, we upgraded to try and stop the seg fault... > > thanks! > > -------------------------------------------------------------------------- - > > > > ATTENTION! Do NOT reply to this email! > To reply, use the web interface found at http://bugs.php.net/?id=9136&edit=2 > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.dev (#45916) next »