Debugging Dynamic Memory Usage Errors Using HP WDB (766161-001, March 2014)
NOTE:
• To get the latest dangling pointers and dangling blocks details for a particular block number
<num>, you must first enter the info dangling command followed by info dangling
<num>.
• WDB tries to help as much as possible to detect if these pointers are of type datum or real
pointers. In a -g compiled binary, WDB performs a look-up on a symbol table to find the
symbol name and type to find the symbol name of the potential pointer and if its of pointer
type, then the corresponding dangling block is really dangling (not a false positive).
Scrambling a Heap Block
The set heap-check scramble <on/off> command enables you to scramble a heap block
and overwrite it with a specific pattern ("0xfeedface") when it is allocated or de-allocated.
If the application continues to use (read) a freed block (incorrect memory usage), the application
fails to find the expected data in the block. (This means that the data in the block is different from
the initial data that was written in the block.)
This increases the chances of the application to crash or result in unpredictable program behavior
sooner with the unexpected data that is read from the block. Additionally, you can detect this
condition with assertion checks in the code to validate the read data during the further run of the
application.
This command does not detect the corruption. It is only a minimal aid to detect corruption.
Example 14 (page 45) illustrates the scramble feature in WDB.
44