Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)

Example 20 Detecting de-allocation of memory that has not been initialized
Sample Program
$ cat unalloc.c
1 #include<stdio.h>
2
3 int main() {
4
5 printf("Starting program\n");
6 char* han;
7 free(han);
8 }
Sample Debugging Session
gdb) set heap-check on
(gdb) file unalloc
Reading symbols from unalloc...done.
(gdb) b main
Breakpoint 1 at 0x2bb4: file unalloc.c, line 5 from unalloc.
(gdb) r
Starting program: unalloc
Breakpoint 1, main () at unalloc.c:5
5 printf("Starting program\n");
(gdb) n
Starting program
7 free(han);
(gdb)
warning: Attempt to free unallocated or already freed
object at 0x70fee070
0x70e78d7c in __rtc_event+0 ()
from /opt/langtools/lib/librtc.sl
98