Re: Recursive PHP method crashes Apache

From: Date: Fri, 04 Jan 2008 09:46:26 +0000
Subject: Re: Recursive PHP method crashes Apache
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-28684@lists.php.net to get a copy of this message
Aaron Schiff wrote:
I call my method Assembler::PrefetchComponents with an array of valid components and it crashes only when I include the line "self::PrefetchComponents($dependencies);" Please help me solve the error in this code.
The code below is an infinite loop. Unless there is an error (assuming Error::ThrowError halts execution), at no point does it return and at the end of the function it calls itself. This will never end. Apache crashes because it fills up the stack.
Here's Assembler::PrefetchComponents: public static function PrefetchComponents($names) { $failed = array(); if(sizeof($m_arrComponents) > 0) { $names = array_filter($names,create_function('$var', 'return(Assembler::GetComponentByName ($var))==NULL;')); } $dependencies = array(); foreach($names as $name) { if(self::TryIncludingComponent($name)) { $dependencies = array_merge($dependencies, call_user_func(array("Component_$name", "Dependencies"))); } else { $failed[] = $name; } } if(sizeof($failed)!=0) { sort($failed); Error::ThrowError(CBD_NO_COMPONENT, $failed); } self::PrefetchComponents($dependencies); }
I'm thinking that last line should be...
        if (count($dependencies) > 0)
        {
                self::PrefetchComponents($dependencies);
        }
-Stut -- http://stut.net/

« previous php.windows (#28684) next »