Mail Archives: djgpp/1996/08/14/21:46:24
Hans-Bernhard Broeker wrote:
> > Anyway, I can't seem to debug it, because when I run the program under
> > fsdb and single step, run etc the program, it runs fine!!!
>
> ... which clearly indicates that you, like every C programmer
> sometimes does, managed to screw up the stack or heap management.
> Programs changing behaviour when run in a debugger typically do
> so because they use the values found in uninitialized storage.
> Be sure you initialize all variables before you use them. Additionally,
> you might want to compile with '-Wall' and look if any of the places
> where gcc warns you about 'value used before it is initialized' might
> be the culprit.
Another way to determine if your program is referencing or otherwise using
uninitialized memory is to include <crt0.h> and add the following line to
your global variables:
_crt0_startup_flags = _CRT0_FLAG_FILL_DEADBEAF;
This causes all memory to be initalized with 0xdeadbeaf when it is
allocated. If you see any variables with this value (or a fragment of
it) then you are using uninitialized memory. It's worked for me any
number of times. :)
--
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>+ W+>++ N++ o+ K? w(---) O-
M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+ tv+() b+++ DI++ D++ G e(*)>++++
h!() !r !y+()
------END GEEK CODE BLOCK------
- Raw text -