Debugging Dynamic Memory Usage Errors Using HP WDB v6.3 (5900-2181, August 2012)
Example 21 Detecting de-allocation of un-allocated blocks
Sample Program
$ cat unit.c
1 #include<stdio.h>
2
3 int main() {
4
5 printf("Starting program\n");
6 int *han = (int*)malloc(sizeof(int));
7 han++;
8 free(han);
9 }
Sample Debugging Session
(gdb) set heap-check on
(gdb) file uninit
Reading symbols from uninit...done.
(gdb) b main
Breakpoint 1 at 0x2bdc: file uninit.c, line 5 from uninit.
(gdb) r
Starting program: uninit
Breakpoint 1, main () at uninit.c:5
5 printf("Starting program\n");
(gdb) n
Starting program
6 int *han = (int*)malloc(sizeof(int));
(gdb)
7 han++;
(gdb)
8 free(han);
(gdb)
warning: Attempt to free unallocated or already freed
object at 0x4042c3e4
0x70e78d7c in __rtc_event+0 () from /opt/langtools/lib/librtc.sl
78