This is an offbeat question that i'm sure only the best of programmers could answer. (I am not in that categorie)

What is it that actually limits the size of the stack.

Is it memory...or the intrinsic architecture of the processor. :grin:
Posted on 2001-09-02 23:50:02 by titan
Well.... of course the answer is it depends...

If you're running an early version of a PIC chip, the stack is two entries deep. Period, and they are in hardware, so that's all.

In a Pentium, the stack starts at some address, and 'grows' downward in physical address numbers until it runs into something else. I believe you get a meg of stack without even trying.

I don't have any idea what protection there is, meaning if you overrun the next memorty segment will a GPF be called, or will you just run amok.

That's all I've ever needed to know about stacks. That's my story, and I'm sticking to it.
Posted on 2001-09-03 00:34:10 by Ernie
The only thing that limits the stack is the memory management. That's the simple answer - I don't know all the details for windows memory management limitations, but I do know that is where the limitations reside. :)
Posted on 2001-09-03 00:44:12 by bitRAKE
Under standard compile, and this test app:

DEBUGC equ 1
.model flat,stdcall
option casemap:none
include \masm32\include\
include \masm32\include\
include \masm32\include\
include \masm32\include\
include \masm32\include\
include \masm32\include\
include \masm32\include\
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib

DPrintValH esp, "Start Stack Val"
push ebx
mov ebx, 2
push eax

xor edx, edx
mov eax, ebx
mov ecx, 10000
div ecx
.if (edx == 0)
DPrintValD ebx, "Successfully Pushed"
inc ebx
jmp bac

call ExitProcess
end start

It crashed at over 250,000 push's. Taking the ESP info from the GPF (00542000h) and subtracting it from the initial stack value (0063fe18h), yeilds (000FDE18h) bytes pushed, or in the sense of DWORD, (000FDE18h)/4 = 0003F786h or in decmal this is 259,974 DWORDS before windows pukes... and confirming the general info of being greater than 250 K dword push's, but less than 260 K pushes. (There is an error of more 8 DWORDS, since Ernie uses "pushad" in his DMacros).

That was fun..
Posted on 2001-09-03 01:57:59 by NaN

The limit is basically what you set in the linker options under STACK RESERVE / STACK COMMIT.

There will be a physical limit but it may be very large.

Posted on 2001-09-03 04:55:50 by hutch--
Well that was very informative.

Lots to play with:alright:
Posted on 2001-09-03 10:02:52 by titan