[SDL] SDL_crash -- fatal error catching with user callback

Nathaniel J Fries nfries88 at yahoo.com
Thu Mar 28 13:49:58 PDT 2013

Mason Wheeler wrote:
> Fatal error catching with user callback? Is this actually something anyone needs?
> Or, phrased another way, is anyone actually programming with SDL in C, and not some higher-level language that supports exception handling?

This is 100% pure C, contained in two files (and now taking 7kb).
C++/C#/Java exceptions are not "fatal errors" - they can not only be caught, but any novice programmer can recover completely from a thrown exception.
Fatal errors refer to things like corrupted heaps, stack overflows, illegal instructions, null-pointer errors, etc; which are all errors that are actually more likely in lower-level languages such as C.

SDL_Crash wraps Windows and POSIX methods for catching fatal errors to provide a single portable interface. On Windows in particular, the APIs are poorly documented and rarely used (in fact, the only good source of information on the matter that I'm aware of comes from Matt Pietrick's 'Under the Hood' column in MSJ from the late '90s). On POSIX, these are just signals, which are both well documented and frequently used (see SDL, which uses these to catch fatal errors and exit gracefully, but unfortunately doesn't provide support for a callback).

I've used similar [but C++-restricted] methods before (specifically, in Open-Tibia Server and Yet Another Tibia Client), and found them to be extremely useful in identifying the source of a fatal error.

Nate Fries

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130328/9e583e8a/attachment-0009.htm>

More information about the SDL mailing list