Mail Archives: djgpp/1997/11/02/19:50:07
Roman Suzi wrote:
>
> How can I control stack overflow?
>
> For SIGSEGV, SIGFPE, SIGINT, etc.,
> no memory (to alloc by new) I've found solutions.
>
> But how to handle General Protection Faults,
> caused by stack overflow? Are there any civilised ways?
>
> (I dont like my programs to have a possibility to crush
> without getting control to some customisable routine)
DJGPP programs, by default, use a fixed size stack that defaults to
256KB. You can increase this default value by 'stubedit'ing the image
or by setting the global variable _stklen in your program. However, you
may still need to look at your code to make sure that you aren't using
more stack than is necessary. Check for:
- Large automatic arrays.
- Deeply recursive functions.
- Overuse of 'alloca()'.
Any program that needs more than 256K of stack _without_ deep recursion
is probably wasting a lot of space.
More information about the stack and how to deal with it can be found in
chapter 15.9 of the FAQ (v2/faq210b.zip from SimTel or online at
http://www.delorie.com/djgpp/v2faq/).
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com |
| Plan: To find ANYONE willing to | http://www.cs.com/fighteer |
| play Descent 2 on DWANGO! | Tagline: <this space for rent> |
---------------------------------------------------------------------
| Plan: To find ANYONE willing to | http://www.cs.com/fighteer |
| play Descent 2 on DWANGO! | Tagline: <this space for rent> |
---------------------------------------------------------------------
- Raw text -