Search code examples
c++wtl

How to diagnose Access Violation on application exit


I have an application that I'm trying to debug a crash in. However, it is difficult to detect the problem for a few reasons:

  • The crash happens at shutdown, meaning the offending code isn't on the stack
  • The crash only happens in release builds, meaning symbols aren't available

By crash, I mean the following exception:

0xC0000005: Access violation reading location 0x00000000.

What strategy would you use to diagnose this problem?

What I have done so far is remove as much code from my program until I get the bare minimum that will cause the crash. It seems to be happening in code that is statically linked to the project, so that doesn't help, either.


Solution

  • You can make the symbol files even for the release build. Do that, run your program, attach the debugger, close it, and see the cause of the crash in the debugger.