home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5340 < prev    next >
Encoding:
Internet Message Format  |  1992-08-16  |  1.8 KB

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