B A T C H R E C U R S I O N exceeds STACK limits

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
SirJosh3917
Posts: 35
Joined: 02 May 2016 18:59

B A T C H R E C U R S I O N exceeds STACK limits

#1 Post by SirJosh3917 » 01 Aug 2019 16:24

Hi, I recently got this message printed to me - is this documented anywhere? is this known?

Image

This message I did not write:

Code: Select all

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

ShadowThief
Expert
Posts: 894
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: B A T C H R E C U R S I O N exceeds STACK limits

#2 Post by ShadowThief » 01 Aug 2019 20:44

This happens when you've got setlocal in a loop somewehere. According to that error message, your script ran setlocal without endlocal 593 times.

jeb
Expert
Posts: 907
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: B A T C H R E C U R S I O N exceeds STACK limits

#3 Post by jeb » 02 Aug 2019 01:01

Hi,

the error is not related to setlocal, but to the call stack.
Probably you have a recursion in your code, like

Code: Select all

:recursion
call :recursion

Looge
Posts: 3
Joined: 25 Jun 2019 07:21

Re: B A T C H R E C U R S I O N exceeds STACK limits

#4 Post by Looge » 06 Aug 2019 08:10

Batch recursion can be caused by various means, but essentially you ...

... well, have a batch recursion. Somewhere.

I occasionally hit that problem, and in my case it always is this:
I have a big collection of scripts, and a very limited set of them are scripts that called by others, but do not do many calls on themselves.
These are sort of small but essential basic scripts, that are often called in the start of a lot of other "normal" scripts.
If then I make a change in such a special script, calling another script, I end up calling a regular script, that starts with calling the script that was the caller in the first place.
And yes, if the call is unconditional ... that's how I create batch recursions.

Post Reply