www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/02/28/03:20:25

Date: Wed, 28 Feb 1996 10:07:51 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: j DOT aldrich6 AT genie DOT com
Cc: djgpp AT delorie DOT com
Subject: Re: GDB discovers another one!
In-Reply-To: <199602280721.AA076212087@relay1.geis.com>
Message-Id: <Pine.SUN.3.91.960228095408.11106X-100000@is>
Mime-Version: 1.0

On Wed, 28 Feb 1996 j DOT aldrich6 AT genie DOT com wrote:

> seems that in allocating the stack space necessary to store the local
> variables in my function, the stack grew so large that it actually overwrote
> segments of static storage!

The DJGPP FAQ list (faq200b.zip from the same place you get DJGPP) has 
the solution to such problems in section 15.8.  There is an entry in the 
Topic Index at the end of the FAQ which says:

  * Stack size, insufficient, causes programs to crash: Section 15.8.

Short answer: run `stubedit' on your program and crank up the default 
stack.  Long answer: read that section in the FAQ.

> My question is:  Why didn't my program report a stack overflow error?

There is no stack overflow checking in DJGPP.  (I'm not even sure it is 
possible under DPMI.)

> Is this a bug in GCC, or is it supposed to leave it up to me to detect
> the possibility?

GCC has nothing to do with the runtime environment in which DJGPP 
programs run.  It is all set up in the library code which is 
DJGPP-specific.

>             I will admit that using 250K for local variables is a bit
> excessive, and I have rewritten the functions so as to dynamically allocate the
> required space, but still, shouldn't it have told me first?

By default, there is a 256K-long stack.  Anybody who uses 250K for local
variables, should set _stklen to an appropriate value (see the FAQ for
details), even before the program is run the first time.  For that matter,
when you write a program which uses so much stack space, you should worry
in *any* environment (IMHO) and check whether such high stack space
consumption is at all possible. 

- Raw text -


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