Mail Archives: djgpp/1996/07/08/09:23:15
On Mon, 8 Jul 1996, A.Appleyard wrote:
> (2) How can I trap the error condition of the stack running out of space?
AFAIK, you can't. The main reason is that there is no such error
condition. When the stack overflows, it just begins overwriting the
heap. How fast and how hard will this cause a crash, depends on the
program.
A tool written by Charles Sandmann is available that can be used to
determine the maximum stack space used by a DJGPP v2 executable during a
given run (note that even this is a non-trivial task). If you want to
release your program and suspect that it might use excessive amounts of
stack space, you should use that tool to see how much stack does it
actually use, then set _stklen and stubedit the executable to a value
slightly larger than that maximum.
Since you seem to be very concerned by this issue, let me tell you 2
things that might help you feel better:
1) The fixed maximum stack is a ``feature'' of many other C
compilers. For instance, Borland C 3.x defines by default a 8KB stack.
2) Most programs are quite happy with the 256KB default. In fact,
a rare C program ever needs more than 50KB (I don't know about C++). Even
GNU Emacs is only stubedited to 512KB, and it never crashed for me. cc1
and cc1plus that sometimes need as much as 750KB are an exeception, not a
rule.
- Raw text -