flat assembler
Message board for the users of flat assembler.

Index > Windows > What is the default stack size or how can I change it?

Author
Thread Post new topic Reply to topic
mindflyr



Joined: 19 Feb 2005
Posts: 6
Location: New Hampshire, USA
mindflyr
I'm modifying the minipad.asm example. It says PE GUI 4.0 or something like that. I want to make sure I'm not going to run into stack problems, so I'm asking about the default stack size since it isn't mentioned in minipad.asm. Also in the online documentation, I must have missed the information on the stack setup. Any help?

_________________
Alison Krauss fan.
Post 19 Feb 2005, 15:08
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7715
Location: Kraków, Poland
Tomasz Grysztar
http://flatassembler.net/docs.php?article=manual#2.4.2:
Quote:
stack directive sets up the size of stack for Portable Executable, value of stack reserve size should follow, optionally value of stack commit separated with comma can follow. When stack is not defined, it's set by default to size of 4096 bytes.
Post 19 Feb 2005, 15:23
View user's profile Send private message Visit poster's website Reply with quote
mindflyr



Joined: 19 Feb 2005
Posts: 6
Location: New Hampshire, USA
mindflyr
Thank you, Privalov. From your newest programmer, mindflyr.
Post 19 Feb 2005, 16:16
View user's profile Send private message Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
I was wondering that if you want to use compiled HTML Help on Win98 (some ActiveX stuff), your program must have at least 64Kb of stack to lunch the help, even if the program actually only needs 1Kb. A terrible waste of stack.
The hell knows what they wanna store in there. Perhaps some nice pics Wink
Post 21 Feb 2005, 10:33
View user's profile Send private message Reply with quote
calm_observer



Joined: 08 Jan 2005
Posts: 17
Location: New Nexico, USA
calm_observer
MCD wrote:
I was wondering that if you want to use compiled HTML Help on Win98 (some ActiveX stuff), your program must have at least 64Kb of stack to lunch the help, even if the program actually only needs 1Kb. A terrible waste of stack.
The hell knows what they wanna store in there. Perhaps some nice pics Wink


One of the reasons windos requires alot of stack space is because the winproc preceedures are reentrable and each time you reenter you recreate all of your local variables.

Also the stack space, I believe, is reserved not committed so you while you use up virtual address space you may not use up physical ram.

_________________
EDUCATION, n.
That which discloses to the wise and disguises from the foolish their lack of understanding.
Post 21 Feb 2005, 17:23
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
calm_observer wrote:
One of the reasons windos requires alot of stack space is because the winproc preceedures are reentrable and each time you reenter you recreate all of your local variables.


Yes, all this is true, but it can not be the case. The stack in Win32 should grow automatically when the program needs more stack space. So, in principle you can begin with 4k stack and leave to Windows to allocate as big stack as application needs.
The only problem with this schema is that the application must allocates at once maximum of 4kbytes stack memory (i.e. the next stack access must be less than 4kbytes above the current address in esp.
Maybe WinHlp (or whatever is the name of HTML-help engine) allocates at once more than 4k and thus broke the stack. Definately this is a bug and shame on MS - it is still not fixed. BTW: this also means that if your application uses some bigger amount of the stack, (in normal manner) even 64k can be not enough.

Hm: what about if we prepare the stack not as a initial PE stack, but immediately before calling HTML-help functions. This can be done with simple loop from $00 to $0f that decrease esp by $1000 and read one byte from the stack (mov eax, [esp]) - thus forcing Windows to allocate the memory.

Regards.
Post 21 Feb 2005, 17:43
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
calm_observer



Joined: 08 Jan 2005
Posts: 17
Location: New Nexico, USA
calm_observer
JohnFound wrote:
...Yes, all this is true, but it can not be the case. The stack in Win32 should grow automatically when the program needs more stack space...

Now that you mention it I do recall reading this somewhere.
JohnFound wrote:
Hm: what about if we prepare the stack not as a initial PE stack, but immediately before calling HTML-help functions. This can be done with simple loop from $00 to $0f that decrease esp by $1000 and read one byte from the stack (mov eax, [esp]) - thus forcing Windows to allocate the memory.

Win32Forth ttp://win32forth.sourceforge.net/ in fact does something like this, however I had assumed it was to make sure that the memory was actually committed, but after your explaination I think it was more in line with your explaination. BTW I'm going to download Fresh and give it a go Cool

_________________
EDUCATION, n.
That which discloses to the wise and disguises from the foolish their lack of understanding.
Post 21 Feb 2005, 19:19
View user's profile Send private message Reply with quote
calm_observer



Joined: 08 Jan 2005
Posts: 17
Location: New Nexico, USA
calm_observer
Sorry about my last post an h got left out of the link:

http://win32forth.sourceforge.net/
Post 21 Feb 2005, 19:38
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
calm_observer wrote:
BTW I'm going to download Fresh and give it a go Cool


Any opinion is welcome. Smile
Post 21 Feb 2005, 20:35
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Quote:

The only problem with this schema is that the application must allocates at once maximum of 4kbytes stack memory {...} Definately this is a bug and shame on MS - it is still not fixed.

It's not a bug, it's an inherent property of using guard pages for growing the stack. If you have >4k local variables, you need to do stack probing - the HLL's I've seen does this automatically.

I do wonder what the problem with HtmlHelp is. RichEdit also needs a big initial stack.
Post 23 Feb 2005, 12:46
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.