delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/02/19:50:07

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [Q:] How to fight General Protection Faults?
Date: Mon, 03 Nov 1997 03:10:37 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 36
Message-ID: <345D40AD.7C3@cs.com>
References: <AB-8pMqag7 AT rsuzi DOT pgu DOT karelia DOT ru>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp228.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019