Insure++ Reference - HEAP_CORRUPT
This error is generated when Insure++ detects that the
heap has been corrupted. These messages can only be generated if the
malloc_replace
option is on.
Typically, Insure++ will identify a serious problem before it
corrupts the heap. If the corruption occurs in code which was not compiled
with Insure++, however, it may not be found for a while. Hopefully,
you will discover that the problem is in a file for which you have source
code. If this is the case, you can recompile that file with Insure++
and continue debugging.
One simple way to generate this error is to corrupt memory in a routine
not compiled with Insure++.
Compile the program with your normal compiler and link it with
Insure++, e.g.
cc -g -c heapbad.c
insure -g -o heapbad heapbad.o
./heapbad
1: /*
2: * heapbad.c
3: */
4: #include <malloc.h>
5:
6: main() {
7: int i;
8: char *c = (char *) malloc(10);
9:
10: for (i = 10; i < 20; i++)
11: c[i] = 'a';
12: free(c);
13: }
1. [malloc.c:1151] **HEAP_CORRUPT**
2. Pointers between this and adjoining blocks are invalid.
3. Corrupt block : 0x00049928 thru 0x00049ab8 (401 bytes)
The chain was last validated at the following stack trace:
malloc() malloc.c, 532
_Insure++_alloc_stack()
_Insure++_assignb()
_Insure++_direct_malloc()
malloc() malloc.c, 670
4. main() heapbad.c, 8
5. Bus error (core dumped)
- Source line at which the problem was detected.
- Description of the problem - this may or may not be
particularly useful.
- A description of the block at which the error was detected.
This block may or may not be the cause of the error.
- Stack trace showing the last time the heap was checked and
found to be okay.
- Core dumps typically follow these messages, as any usage
of the dynamic memory functions will be unable to cope.
Since the above message seemed to occur in the file
heapbad.c , which was not processed with
Insure++, the simplest thing to do is process this file with
Insure++.
insure -g -o heapbad heapbad.c
In this case, the bug is quickly identified as a
WRITE_BAD_INDEX , and can
be repaired accordingly.
FUNC_WILD
INSURE_ERROR
|