Mail Archives: djgpp/1998/03/31/03:23:28
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 -