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

From: Date: Wed, 07 Feb 2001 09:11:38 +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-45934@lists.php.net to get a copy of this message
On Wed, 7 Feb 2001, Boian Bonev wrote: > 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. This gives a problem itself, how many levels before the stack is full? Not every function call has the same memory footprint, so you can't tell after how many levels the stack is full. Derick Rethans --------------------------------------------------------------------- PHP: Scripting the Web - www.php.net - derick@php.net --------------------------------------------------------------------- JDI Media Solutions - www.jdimedia.nl - d.rethans@jdimedia.nl H.v. Tussenbroekstraat 1 - 6952 BL Dieren - The Netherlands ---------------------------------------------------------------------

« previous php.dev (#45934) next »