We write high quality code, but a crash is always possible. So what do you do if it your program crashes? Simple, you analyze the crash dumps, find out where and why it is crashing and fix it. But, what if the crash is not repeatable? Be prepared. The best thing to do is to install a crash dump tool on the computer where the software is going to be run/tested.
When a program error occurs in Windows, the operating system searches for a program error handler to deal with the error. If the system does not find such a handler, the system verifies that the program is not currently being debugged, and if not, it considers the error to be unhandled. The system then processes unhandled errors by looking in registry for a program error debugger. An example error handler is dr watson.
To install Dr. Watson as your crash dump analysis tool, follow these simple instructions here
To install Debugging tools for windows as your crash dump tool, do the following:
Install it into your folder of choice, example: C:\Program Files\Debugging Tools for Windows.
Register Debugging tools for windows as your default debugger, by running this command from the command prompt: "C:\Program Files\Debugging Tools for Windows\WinDbg" -i" You should see this message confirming that WinDbg is your postmortem debugger:
Run regedit (from start->run) and modify this key: HKLM\software\microsoft\windows nt\currentversion\aedebug. Change the value of the key Debugger (creating it if necessary) to the following:
Any dump files from any programs from now on, will be put in C:\dumps\ with a .dmp extension.
Now that you have the dump file, take the .exe and .pdb files of the crashing program, drop them in your code's output directory and double click on the .dmp file. Visual studio will open a dump project for you. Start debugging your program, and it will show you where it crashes. This assumes that you built your program with debug symbols and moderate optimization (or no optmization). If you don't know how to do that, well, ask Google.