From: "John M. Aldrich" 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: Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp228.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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: | --------------------------------------------------------------------- | Plan: To find ANYONE willing to | http://www.cs.com/fighteer | | play Descent 2 on DWANGO! | Tagline: | ---------------------------------------------------------------------