Wednesday, August 19, 2015

Debugging memory errors using Application Verifier

Debugging memory management errors

Few days ago, one of my applications started crashing both on Linux and Windows because of a memory corruption. Many tools are available to debug such issues; I usually use the open source valgrind on Linux, while I prefer instrumentation based tools on Windows.
But the application I had to debug was so large that the instrumentation based tools either failed to instrument it or succeeded in instrumenting the binary but then failed quite soon at runtime. Valgrind was successful in running my application, but generated such a large number of false positives that it was really difficult to locate the source of the error I was interested at.
I finally found information about Application Verifier and tried it for the first time: and it was really successful in helping me finding the memory issue, by pinpointing the line of code that executed the wrong memory access.
The reminder of this article shows how to use Application Verifier to debug memory issues, using a simple example.