Stack overflow in user-mode?

One of my co-workers got a Dr. Watson for their user-mode application saying
that it got a stack overflow. Looking at it, it died in the CRT library,
and there was one of my co-workers routines which called it which used
nearly 1 MB of stack space.

My first reaction – being a kernel-mode guy – was one of shock that thier
program worked at all with a local stack which was that large. However,
this is code that we’ve been shipping for quite some time and this is the
first time that it’s happened.

However, then I remembered that in user-mode, the stack overflow exception
is supposed to get handled and then the stack grows in 4 KB chunks or
somesuch.

So why did they get a stack overflow – shouldn’t there be infinite stack
(assuming that virtual memory doesn’t run out)? Or is there a sanity limit
of 1 MB?

The default maximum stack size for applications built with VC is 1MB. The
maximum size (stack reserve) and the initial size (stack commit) is in the
EXE header.
The stack grows in 4KB chunks until the maximum is reached.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Taed Wynnell
Sent: Friday, August 09, 2002 6:40 PM
To: NT Developers Interest List
Subject: [ntdev] Stack overflow in user-mode?

One of my co-workers got a Dr. Watson for their user-mode application saying
that it got a stack overflow. Looking at it, it died in the CRT library,
and there was one of my co-workers routines which called it which used
nearly 1 MB of stack space.

My first reaction – being a kernel-mode guy – was one of shock that thier
program worked at all with a local stack which was that large. However,
this is code that we’ve been shipping for quite some time and this is the
first time that it’s happened.

However, then I remembered that in user-mode, the stack overflow exception
is supposed to get handled and then the stack grows in 4 KB chunks or
somesuch.

So why did they get a stack overflow – shouldn’t there be infinite stack
(assuming that virtual memory doesn’t run out)? Or is there a sanity limit
of 1 MB?


You are currently subscribed to ntdev as: xxxxx@bwandel.com
To unsubscribe send a blank email to %%email.unsub%%

A common cause of app stack overflow is recursion gone astray. It can also
happen if the app has big local data objects: one quick way of checking that
is to artificially decrease the size of those objects (typically arrays) or
to make them global instead of local. Another way to do it is to take
advantage of the C++ functionality and make them dynamic objects that get
allocated on the heap.

Hope this helps !

Alberto.

-----Original Message-----
From: Bill Wandel [mailto:xxxxx@bwandel.com]
Sent: Friday, August 09, 2002 8:00 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Stack overflow in user-mode?

The default maximum stack size for applications built with VC is 1MB. The
maximum size (stack reserve) and the initial size (stack commit) is in the
EXE header.
The stack grows in 4KB chunks until the maximum is reached.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Taed Wynnell
Sent: Friday, August 09, 2002 6:40 PM
To: NT Developers Interest List
Subject: [ntdev] Stack overflow in user-mode?

One of my co-workers got a Dr. Watson for their user-mode application saying
that it got a stack overflow. Looking at it, it died in the CRT library,
and there was one of my co-workers routines which called it which used
nearly 1 MB of stack space.

My first reaction – being a kernel-mode guy – was one of shock that thier
program worked at all with a local stack which was that large. However,
this is code that we’ve been shipping for quite some time and this is the
first time that it’s happened.

However, then I remembered that in user-mode, the stack overflow exception
is supposed to get handled and then the stack grows in 4 KB chunks or
somesuch.

So why did they get a stack overflow – shouldn’t there be infinite stack
(assuming that virtual memory doesn’t run out)? Or is there a sanity limit
of 1 MB?


You are currently subscribed to ntdev as: xxxxx@bwandel.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.