Catching a faulty image with Structured Exception Handling

Published January 06, 2007
Advertisement
Work continues on ThumbView2, albeit slowly. Today a bug occurred, and just as it did in ThumbView1 it crashed and brought Windows (explorer.exe) down with it. Since ThumbView is a shell extension, it's a COM object run from a DLL by the OS shell itself. So if the DLL crashes, so does the shell.



As with the first version, the crash wasn't from the ThumbView code I've written but from the 3rd party image loading library failing to load an image. I don't have much power over that, and even if I did it would be too late since it's already crashed a users computer - that's not nice now is it?

Naturally, I have to run the image loading in some safe way. An own thread? An own DLL? Something! The answer came with structured exception handling (SEH). The __try and __except blocks lets me catch and handle both software and hardware exceptions. So dereferenced null-pointers and the like get catched! Right now I just log the error with OutputDebugString and read that with DebugView.



Completely superior! Holy banana! The faulty image is ref.xwd but I just didn't print that, since it would be too useful. ^^

So now I can detect that an image broke the image library. That's hawt if you're the image library writer. To fix that you'll need the actual image. For ThumbView though. What should happen?
* Display a default "broken image" icon?
* Tell the user with a MessageBox that a broken thumbnail was encountered and I'd like him to report the error?
* Just report the error anyway?
* Log the error?
* Allow error report on right-click?
* Erase all .sys files on the hard drive?

Because what I want from the user is: the ThumbView version, OS version, full image file path (to find Unicode problems), and of course the image. I'd like a system that asked the user if I could have the data, collected it, compressed it to a zip, and send it over! But I'll have to log the image so I don't report it more than once; since the user will get annoyed by the system asking to send a report every time he reloads a folder with a broken image...
0 likes 2 comments

Comments

Jotaf
Man, there's NOTHING more annoying than message boxes popping up all the time! They trigger the same natural response that you have for spam. :P So I wouldn't go with that.

Ok, here's how I would do it:
1) Don't bother sending files over 200kb or so (send the report but not the file). I wouldn't want to upload 5megs just to give the developer debug information!
2) Pop up one of those yellow tip boxes, posing the problem and asking to click. Then a more elaborate textbox shows up - send a report or forget it. Maybe the image is a bit too cheeky to send. +:o)
3) Either choice will throw the file in a list so that the program remembers not to bother the user with it anymore. Better than a list, attach the info to the file (no clue how this would be done though! :P ).
4) If you have a list, clean it up from time to time. Chose a few files at random and check if they're still there.

Huh... I guess that would work ok :)
January 07, 2007 07:22 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement