OK that sounds like an oxymoron. A crash, good? Thats crazy talk!
Well maybe not quite that crazy – read on to find out why…
Why would anyone actually want their app to crash you may ask? To answer that question lets cover some background about why applications crash on Windows (or any OS).
An application crashes when it performs an unexpected operation or encounters what is called an “exception condition”. Exceptions include unwanted operations like writing to invalid memory locations, divide by zero errors, page faults, etc. Programs can end up with exceptions like this for a variety of reasons:
- bugs in the progam code
- bugs in loaded DLL’s which share the same memory and address space as the host application. You frequently encounter dll’s via plug-in’s in applications (eg. loading a VST in an audio application or a imaging plug-in in Photoshop)
- bugs in the operating system
Normally when an error like this occurs, Windows will display the familiar error message “This Program Has Performed an Illegal Operation and Will Be Shut Down” and the program will close. Some applications like SONAR handle such errors more gracefully and will even try and intercept these exception and attempt to allow the user to save their work before exiting the program. Additionally on Windows you can choose to save what is called a Minidump containing “post mortem” debugging info that is very useful to developers to find out why the program crashed.
How to make your application crash gracefully on 64-bit Windows
Recently we began noticing a pattern where we were receiving Minidump’s from crashes on from 64 bit Windows systems X64 where the dumps contained useless or apparently invalid information about the crash. This made it very hard for us to diagnose such issues. I was even able to reproduce this by writing a simple test application that forced a crash. In one case I found that the crash was reported in a completely different location and in another the application behaved as if the exception didn’t occur!
The scenario above is is actually very bad from both a users and the developers point of view, since when damage is done to a running application the best scenario is to actually shut it down or risk data corruption or worse damage. So you really WANT your app to crash when something like this happens. I logged a bug with Microsoft about this issue using a test application. I recently heard back from their developer support about this issue. It turns out to be an interesting problem that Microsoft is aware of and have issued a hotfix for.
Here is a link to a Microsoft blog post describing this problem in gory detail if you want to read more about it.
And here is the link to the hotfix if you want it now. This hotfix will also be rolled into Windows 7 SP1. I hope that this is not required in the final version but currently the fix requires you to set a value in the registry to enable it.