home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: array bug
- Message-ID: <1992Aug17.003105.28165@netlabs.com>
- Date: 17 Aug 92 00:31:05 GMT
- References: <Bt1rC8.E6J.1@cs.cmu.edu>
- Sender: news@netlabs.com
- Organization: NetLabs, Inc.
- Lines: 38
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <Bt1rC8.E6J.1@cs.cmu.edu> jfriedl@cs.cmu.edu writes:
- : The following (contrived) program dumps core with 4.035
- :
- : &foo;
- : sub foo {
- : ($a, $b) = &foo('fi','b');
- : }
- :
- : I've run it (and had the problem) on Sun 3, Sun 4, IBM-RT,
- : Pmax, Vax, and Luna/88k.
- :
- : Any ideas?
-
- Yes, don't do infinite recursion. It's a bit hard on the virtual
- memory system to grow the stack without limit. You won't find a
- machine in the world that can do it, only machines that appear to let
- you get away with it for a while. Every time you call &foo from within
- &foo, you force the run-time system to remember to schedule another
- assignment to ($a, $b) when the function call returns, and it has to
- remember this by pushing its context onto a stack.
-
- [Yes, there are certain smart compilers that can optimize certain kinds
- of stateless recursion into mere iteration and thus spare the stack,
- but unless you give a terminating condition it'll still run forever...]
-
- It would be nice if Perl could detect infinite regression and give
- you a meaningful message, but in general an OS tells you that you've
- blown it by refusing to give you access to Yet Another Page of Virtual
- Memory, and there's nothing much left to do but dump core. Note however
- that if you run the above with a -w switch it should say
-
- Possible typo: "a" at - line 3.
- Possible typo: "b" at - line 3.
- Deep recursion on subroutine "foo" at - line 3.
-
- It says that when it discovers it's 100 levels deep in unreturned calls.
-
- Larry
-