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

(gdb) c
Continuing.
warning: Memory block (size = 100 address = 0x4042a3c8)
appears to be corrupted at the end.
Allocation context not found
#1 main() at bounds.c:5
#2 _start() from /usr/lib/libc.2
#3 _start() from /opt/langtools/lib/librtc.sl
#4 $START$() from
warning: Use command backtrace (bt) to see the current context.
Ignore top 4 frames belonging to leak detection library of gdb.
0x70e78d7c in __rtc_event+0 () from /opt/langtools/lib/librtc.sl
(gdb) f 4
#4 0x4000960:0 in main () at bounds.c:9
9 free(cp);
(gdb)
Setting the amount of guard bytes for every block of allocated memory
HP WDB enables you to programmatically control the size of guard bytes for every block
of the allocated memory. You can use these guard bytes to spot very rare and non-trivial
boundary (buffer over-run and buffer under-run) corruptions.
The commands which enable you to change the guard byte size are effective only when
bounds-check is turned on.
The following are the command that enable you to set the guard bytes for every block
of allocated memory:
1. set heap-check header-size <no of bytes>
This is used for setting the header guard for each block of memory that is allocated.
The default no of bytes for the footer is 16 bytes if this option is not used. If the user
specifies any number than 16, WDB ignores it and considers the default of 16 bytes.
If the user specifies more than 16 bytes, then the largest closest 16 byte integral of
the user given value is chosen. For example, if the user enters 60 bytes, WDB takes
it as 48; if the user specifies 65, WDB considers it as 64.
2. set heap-check footer-size <no of bytes>
This is used for setting the footer guard for each block of memory that is allocated.
The default no of bytes for the footer is 1 byte, if this option is not used.
Detecting Heap Corruption
The info corruption <filename> command enables you to view the corruption
profile of all the allocations that are corrupted at a specified probe-point in the program.
Ensure that the bounds checking is enabled before using the info corruption
50