www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/22/04:11:20

Xref: news2.mv.net comp.os.msdos.djgpp:7744
From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: memory overwriting itself??
Date: Wed, 21 Aug 1996 19:05:34 -0700
Organization: Three pounds of chaos and a pinch of salt
Lines: 41
Message-ID: <321BC06E.45BE@cs.com>
References: <4ved7k$gps AT news DOT ysu DOT edu>
NNTP-Posting-Host: ppp219.cs.com
Mime-Version: 1.0
To: randall williams <ac387 AT yfn DOT ysu DOT edu>
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

randall williams wrote:
>
> After several steps through directories, the program crashes and I
> get usually SIGFPE, SIGBUS, or out of file handles. GDB showed me
> the divide by zero problem and I found an index counter was 0.
> The index counter is initialized to 1 and should never be zero
> since it only ever counts up. is there any easy way to find this
> bug? is this a bug in gcc? suggestions on narrowing this down?
> 
> The bad thing is that another compiler doesn't have this bug with
> the same source code.

The most likely cause is that your program is using large automatic
arrays which cause it to overflow the default 256K runtime stack.
Because of a "feature" of DPMI, DJGPP is unable to detect when this
occurs, leading to all sorts of nasty effects on the rest of your
program.  There are several things you can try to test for this:

1) Increase the stack of your program by a) setting the global variable
   _stklen within your main program to a high value like 512K or 1024K, or
   b) using the 'stubedit' program to increase the stack of your compiled
   executable.

2) Move any large automatic arrays declared by your program into static
   storage, or allocate them dynamically with malloc() or alloca().

If this doesn't work, repost with the code fragment that crashes and we'll
see what we can do.  The only other cause that I can think of offhand is
a rogue pointer that is overwriting your data and stack space.

BTW, the DJGPP FAQ (v2/faq201b.zip) covers the stack issue in depth in
chapter 15.9.

John

-- 
----------------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I     |       fighteer AT cs DOT com              |
| Proud owner of what might one day   |  Plan: To make Bill Gates suffer   |
| be a spectacular MUD...             |  Tagline: <under construction>     |
----------------------------------------------------------------------------

- Raw text -


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