Mail Archives: cygwin/1999/01/26/07:18:19
On Mon, 25 Jan 1999, Dobes Vandermeer wrote:
>
> I am getting some really weird errors with printf(). Unlike my last
> problem, I *am* including stdio.h, and I do have -Wall enabled. I am
> not getting any warnings or errors, however a step through of my program
> reveals that my data structures (which have been properly malloc()'d
> etc.) are fine immediately before calling printf, and are completely
> ruined after calling printf(). This has happened to me twice now, and
> removing the printf() prevents the data from being destroyed.
90+% of the time, it's a bug in one's code. Usually results from memory
corruption of the following type:
- trashing unallocated memory, eg., writing beyond array limits.
Especially standard C str* runctions, as well as constructs like
a[i], where i >= ARRAY_LIMIT || i < 0.
- free'ing unallocated memory, or free'ing memory multiple times
- just plain bugs in your code.
Your best bet is to really look at your code to see if you can spot
one of these; failing that, my recommendation is to find a Unix box,
eg., Linux, and use one of the free memory debuggers such as
ElectricFence or dmalloc to debug memory (de)allocation errors. I
personally prefer Purify, but that's an overkill for most small
programs.
Regards,
Mumit
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -