Tanktalus has asked for the wisdom of the Perl Monks concerning the following question:

In adding a feature to some of my code, I accidentally (although not entirely surprisingly) managed to create infinite recursion in it. It had the oddest diagnostic message, and it got me wonder, what the heck type of "strange benchmark program" would actually be recursing 100 times? And those who would actually do such things, do they need to be explicitly mentioned here since they probably are way more advanced than I am?

$ nice perl -we 'use strict; use diagnostics; sub foo { foo() } foo()' Deep recursion on subroutine "main::foo" at -e line 1 (#1) (W recursion) This subroutine has called itself (directly or indir +ectly) 100 times more than it has returned. This probably indicates an infinite recursion, unless you're writing strange benchmark progra +ms, in which case it indicates something else.

Note to those crazy enough to run programs listed here without understanding their full implications: Without the "use diagnostics" and the warnings (probably more the latter than the former), this thing can do wierd and wonderful things. It took me about 10 minutes to regain control of my machine just running "perl -e 'sub foo { foo() } foo()'". Don't do that. On my next try, as you saw above, I threw in everything I could to keep it from repeating the behaviour. It did, however, seem to take up huge amounts of RAM, such that I have half my RAM available again, although my swap usage grew by about the same amount...

Replies are listed 'Best First'.
Re: Strange benchmark programs?
by cog (Parson) on Apr 02, 2005 at 21:06 UTC
    those crazy enough to run programs listed here without understanding their full implications

    I sent a note to them yesterday.