Computing.Net > Forums > Programming > recursion exceeded stack limit

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

recursion exceeded stack limit

Reply to Message Icon

Name: Mechanix2Go
Date: April 11, 2005 at 18:43:32 Pacific
OS: w2k
CPU/Ram: PIII 933 / 256
Comment:

I get this:

****** B A T C H R E C U R S I O N exceeds STACK limits ******
Recursion Count=645, Stack Usage=90 percent
****** B A T C H PROCESSING IS A B O R T E D ******

when I run this BAT in w2k:

::**

@echo off > quit.bat

:main

for /L %%N in (1,1,10000) do call :generate

goto :eof

:generate

echo %random% >> random.log

goto :main

::**

Without the goto :main it's OK.

What's going on here?

TIA

M2


If at first you don't succeed, you're about average.



Sponsored Link
Ads by Google

Response Number 1
Name: borelli35
Date: April 11, 2005 at 23:14:03 Pacific
Reply:

What's the name of the batch file you have the source listed here for?

borelli35


0

Response Number 2
Name: Mechanix2Go
Date: April 11, 2005 at 23:15:57 Pacific
Reply:

Here's a little incidental intelligence from M$.

In XP config.nt, the defauly stacks:

IBM PC, IBM PC/XT, IBM PC-Portable 0,0

other 9,128

I guess I'll take my chances with 'other'; don't think I want to run XP on PC/XT.

Unless I eat a whole jar of downers first.

M2


If at first you don't succeed, you're about average.


0

Response Number 3
Name: Mechanix2Go
Date: April 11, 2005 at 23:45:11 Pacific
Reply:

borelli35,

rndtest.bat

M2


If at first you don't succeed, you're about average.


0

Response Number 4
Name: IVO
Date: April 12, 2005 at 03:39:51 Pacific
Reply:

Why did you code a "GoTo :main" at the end of the :generate internall subroutine? In that way you trig a (not required) recursive call of the batch's body itself.

To end a subroutine you have to code just "GoTo :EOF" (that returns to OS if part of the main). You do not need to explicitly set up a loop as the Call is performed by the semantic of For 10000 times.


0

Response Number 5
Name: Mechanix2Go
Date: April 12, 2005 at 04:29:33 Pacific
Reply:

Hi IVO,

Yes, inthis case since there is nothing else to do it has no prctical effect.

But it 'falls through'.

With this code:

::**
@echo off > quit.bat

:main

for /L %%N in (1,1,10000) do call :generate

goto :eof

:generate

echo %random% >> random.log

:somesub

echo somesub

:eof

::**

it does the echo somesub many [probably 10000] times. Which means it has fallen through the :somesub label.

So how to tell :main where :generate ends?

M2


If at first you don't succeed, you're about average.


0

Related Posts

See More



Response Number 6
Name: IVO
Date: April 12, 2005 at 06:33:55 Pacific
Reply:

Hi M2,

you have to code a GoTo :EOF either after the Echo %random% either after the Echo somesub, and the :EOF does not need to be declared as it is hardwired in NT interpreter.

GoTo :EOF means "Return from Subroutine" or (if in main) "Return to the System". see GoTo /? and Call /? for a short tutorial.

So you have to code

:Generate
Echo %random% >> random.log
GoTo :EOF

:somesub
echo somesub
GoTo :EOF

without declaring the :EOF label.


0

Response Number 7
Name: dtech10
Date: April 12, 2005 at 07:51:41 Pacific
Reply:

Hi Mechanic
This handles the stack correctly without droping through.

for /L %%N in (1,1,10000) do call :generate
echo Here
exit /b

:generate
%random% >> random.log
exit /b


0

Response Number 8
Name: Mechanix2Go
Date: April 12, 2005 at 23:12:54 Pacific
Reply:

IVO & dtech10,

Thanks.

Got it.

M2


If at first you don't succeed, you're about average.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: recursion exceeded stack limit

File I/O in C www.computing.net/answers/programming/file-io-in-c/13329.html

large arrays in c++ www.computing.net/answers/programming/large-arrays-in-c/5632.html

Web / Java : Servlet - doGet() www.computing.net/answers/programming/web-java-servlet-doget/12446.html