delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/31/03:23:28

Date: Tue, 31 Mar 1998 11:22:25 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Shawn Rusaw <wasurs AT cs DOT sfu DOT ca>
cc: djgpp AT delorie DOT com
Subject: Re: Program does not run correctly after SIGINT
In-Reply-To: <35201082.7297@cs.sfu.canada>
Message-ID: <Pine.SUN.3.91.980331110944.23311I-100000-100000-100000@is>
MIME-Version: 1.0

On Mon, 30 Mar 1998, Shawn Rusaw wrote:

> 2. Run program - the program collects data
> 3. midway through collecting data, I press <ctrl><c> or <ctrl><brk>
>    which delivers a SIGINT, stopping the program.
> 4. If I try to run the program again, It seems to startup using
>    some of the data from the previous run.
> 
> This sort of thing has never happened before (using BCC or using
> gcc in a Solaris environment). My gut feeling is the stack is
> somehow getting munged, but really don't have a firm grasp what
> to do.

What this seems like is that your program accesses some uninitialized 
memory.  After it has been run once, it leaves behind some memory filled 
with some of the data it worked on, and the second invocation picks that 
up.

Look for unintialized buffers or pointers.

One frequent assumption is that storage allocated by `malloc' is zeroed 
out.  This is true on many Unix systems, but not in DJGPP v2.  The FAQ 
has some advice how to detect such problems in section 9.1, which see.

> Do I need to handle the SIGINT?  Is it done behind the scenes with
> other compilers? (i've used gcc before, and never seen this)

SIGINT just aborts your program.  Apart of not flushing any pending data 
to files you have open in your program, it cannot explain anything bad 
which happens to the next invocation.

> Other posts have metioned stack problems and I cannot find anything 
> in FAQ2.10.

Did you try section 9.1?


- Raw text -


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