Re: Nested functions and stackoverflow
| From: | Ignacio Vazquez-Abrams | Date: | Thu, 14 Dec 2000 15:44:37 +0000 |
| Subject: | Re: Nested functions and stackoverflow | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30303@lists.php.net to get a copy of this message | ||
On Thu, 14 Dec 2000, Rasmus Resen Amossen wrote:
> Look at the following situation:
> In a php-function, say "func()", I "include()" a php-file, say
> "hello1.php".
> Inside "hello1.php" I initialize a variable, say "$var" and create a
> link to another php-file, say "hello2.php".
> In "hello2.php" I check for the existence of "$var" and calls the
> function "func()" if it exists.
>
> Here is the problem:
> If the user follows the link to "hello2.php" the function func() has in
> practice been called inside itself. Or does php clear the stack, when
> the html-page as been generated?
> If not, we got the following situation:
>
> func() {
> func() {
> func() {
> func() {
> func() {
> ...
> ...
> }
> }
> }
> }
> }
>
> -And that MUST produce a stackoverflow some time.
>
> Am I right?!
>
AFAIK, it causes an OOM condition in PHP, halting execution. I can't say
specifically about PHP, but most high-level languages have their own stack
mechanism, and usually don't get affected on stack overflows per se unless
there is some sort of artificial limit imposed.
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>