[comp.lang.perl] recursion problems

tchrist@convex.com (Tom Christiansen) (02/27/90)

I have a resursive subroutine with all local variables 
that is having problems with its return value.  Precisely,
it's saying it's returning a local @list, but when the
return value delivered back to the caller is actually @_[0],
the subroutine's first called-with parameter.

Has anyone else seen this?  When I isolate the routine
into a brief test-case, the problem goes away, as I 
find so often to be the case.  Larry, have you made
any fixes for patch9 that might be related to this problem?

--tom
--

    Tom Christiansen                       {uunet,uiucdcs,sun}!convex!tchrist 
    Convex Computer Corporation                            tchrist@convex.COM
		 "EMACS belongs in <sys/errno.h>: Editor too big!"

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/28/90)

In article <100264@convex.convex.com> tchrist@convex.Com (Tom Christiansen) writes:
: I have a resursive subroutine with all local variables 
: that is having problems with its return value.  Precisely,
: it's saying it's returning a local @list, but when the
: return value delivered back to the caller is actually @_[0],
: the subroutine's first called-with parameter.
: 
: Has anyone else seen this?  When I isolate the routine
: into a brief test-case, the problem goes away, as I 
: find so often to be the case.  Larry, have you made
: any fixes for patch9 that might be related to this problem?

Yes, this sounds exactly like something I fixed.  The problem is that
the stack is getting realloced, and the code for processing the
returned array value was using the old stack instead of the new one.

The reason the problem goes away when you try to construct a test case
is that the stack shrinks and then doesn't realloc at that juncture.

Larry