Please enable JavaScript to view this site.

Memory Validator Help

Navigation: Examples

Finding memory corruptions

Scroll Prev Top Next More

 

Detecting double deallocations

 

The example program is run once and we use the Memory view to observe and investigate any double deallocations.

 

For each double deallocation, Memory Validator displays the allocation and deallocation locations.

 

mvMemVal

 

Memory tab instructionStep Display... instructionStep check Memory Errors if not already checked.

 

menu Settings menu instructionStep Edit Settings... instructionStep Data Collection instructionStep Collect page instructionStep check Memory Buffer detect instructionStep enables the use of Uninitialized Data hooks

 
The target program will run slower than usual with this option as all functions related to strings and memory copying are monitored.

 

launch nativeExample.exe instructionStep wait until attaching is complete

 

 

nativeExample1  

 

menu Memory Errors menu instructionStep Buffer overrun submenu instructionStep Overrun allocated memory instructionStep allocates an array and the end of the array is deliberately overrun

 

mvMemVal

 

In the Memory tab, the overrun corruption is detected and displayed

 

example-memory-corruption1

 

nativeExample1  

 

menu Memory Errors menu instructionStep Buffer overrun submenu instructionStep Underrun allocated memory instructionStep allocates an array and the end of the array is deliberately underrun

 

mvMemVal

 

In the Memory tab, the underrun corruption is detected and displayed

 

example-memory-corruption2

 

nativeExample1  

 

menu File menu instructionStep Exit

 

mvMemVal

 

wait for data transfer to complete

 

Memory tab instructionStep Refresh instructionStep shows the usual leaks and also the two corrupted blocks using the colour defined.

 

example-memory-corruption

 

expand the most recent corruption instructionStep shows the callstack at the point of corruption

 

expand the topmost entry in the callstack instructionStep shows the source at the corruption point in CTeststakView::OnBufferoverrunOverun()

 

example-memory-corruption-expanded

 

Searching for Memory Allocations

 

In the simple code of the example above we can see where the allocation is - on the line above the corruption point.

 

If we didn't know where the memory was being allocated, we can use the query address dialog.

 

Make a note of the object address - e.g. in our example above 0x02137EC8

 

menu Query menu instructionStep Query Address... instructionStep enter the address in Address to search for instructionStep Query instructionStep shows all allocations including that address.

 

This should show a result that can be expanded to show the allocation location as the line above the corruption point we saw above.

 

example-memory-corruption-query-address