PHP infinite recursion

What can I say? How about “toy language”?

$ php -r 'function foo() { foo(); } foo();'
Segmentation fault

I’m not saying that infinite recursion is a good idea, but during development it can happen by accident, and I don’t expect such a simple error to crash the PHP interpreter! (Also it took me about 20 minutes to debug this problem, as I had no idea where it happened, nor indeed what the problem was..)

PHP 5.2.6 on Linux 2.6.26 Debian

4 Responses to “PHP infinite recursion”

  1. Robin Kearney Says:

    I get:

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in Command line code on line 1

    PHP 5.3.0 on osX 10.6.2

  2. adrian Says:

    OK, that is an improvement, esp as it tells you the line number (which is what you want!)

  3. barbara Says:

    i like ;)

  4. Michael Kohl Says:

    You may like this in Bash then:


    :(){ :|:& };:

    Hint: Don’t try this on a system that you are not willing to reboot…

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

For inserting HTML or XML please remember to use &lt; instead of <