The dheap –is_dangling command lets you determine if a pointer is still pointing into a deallocated memory block.
You can also use the dheap –is_dangling command to determine if an address refers to a block that was once allocated but has not yet been recycled. That is, this command lets you know if a pointer is pointing into deallocated memory.
If you set a breakpoint on the printf() statement and probe the addresses of
addr and
misaddr, the CLI displays the following:
This example is contrived. When creating this example, the variables were examined for their address and their addresses were used as arguments. In a realistic program, you’d find the memory block referenced by a pointer and then use that value. In this case, because it is so simple, using the CLI
dprint command gives you the information you need. For example:
If a pointer is pointing into memory that is deallocated, and this memory is being hoarded, the CLI also lets you know that you are looking at hoarded memory.