Insure++ Reference - FREE_WILD
This error is generated when memory is de-allocated that is unknown
to Insure++.
This can come about in two ways:
- Errors in user code that result in pointers that don't point at
any known memory block.
- Compiling only some of the files that make up an application.
This can result in Insure++ not knowing enough about memory
usage to distinguish correct and erroneous behavior.
This discussion centers on the first type of problem described here.
A detailed discussion of the second topic, including samples of its
generation and repair can be found in
"Interfaces".
A particularly unpleasant problem can occur when using union
types. The following code first assigns the pointer element of a union but
then overwrites it with another element before finally attempting to free
the initial memory block.
1: /*
2: * File: freewild.c
3: */
4: #include <stdlib.h>
5:
6: union {
7: int *ptr;
8: int ival;
9: } u;
10:
11: main()
12: {
13: char *a = (char *)malloc(100);
14:
15: u.ptr = a;
16: u.ival = 123;
17: free(u.ptr);
18: return (0);
19: }
[freewild.c:17] **FREE_WILD**
1. >> free(u.ptr);
2. Freeing wild pointer: u.ptr
3. Pointer : 0x0000007b
Stack trace where error occurred:
4. main() freewild.c, 17
- Source line at which the problem was detected.
- Description of the problem and the name of the parameter
that is in error.
- Value of the bad pointer.
- Stack trace showing the function call sequence leading to
the error.
This problem is most conveniently tracked in a debugger by stopping
the program at the indicated source line. You should then examine the
illegal value and attempt to see where it was generated. Alternatively
you can stop the program at some point prior to the error and single-step
through the code leading up to the problem.
"Wild pointers" can also be generated when Insure++
has only partial information about your program's structure. This issue
is discussed extensively in
"Interfaces".
FREE_UNINIT_PTR
FUNC_BAD
|