View Full Version : Detecting first free for double free exception

05-01-2009, 03:11 PM
If I enable the memory debugger, which eventually flags an exception when a double free occurs, how do I determine where the first (valid) free occurred?

05-04-2009, 10:35 AM
Hello Ken,

I've answered this in the support email you sent in, but I'll copy the relevant portion here as well. Assuming you are using the TotalView or MemoryScape GUI, you should get a pop up window for an event notification. This window, in the tabs near the top, should show the event location, where the second free took place. The Allocation Location, where the original malloc occurred. The Deallocation Location, where the first free, the one you are looking for, took place, and the Block details. In both the event location, and the Deallocation Location, the lines tagged are the first line AFTER the actual free, as we are detecting it after the 'free' took place.

If you are using the CLI, or memscript or tvscript to catch this error, things become a little harder to track down, and I think you have to work backwards from the current location. So the GUI is a clear win here.

I hope that helps.