[SDL] SDL_crash -- fatal error catching with user callback
masonwheeler at yahoo.com
Thu Mar 28 14:37:01 PDT 2013
...and most high-level languages will catch "fatal errors" and translate them into exceptions. In Delphi, for example, probably the most common exception encountered while debugging is EAccessViolation--usually as a result of a null pointer dereference--which is caused by the runtime catching Windows error code C0000005 (or its equivalent signal on other OSs) and translating it into an exception. Stack overflows and illegal instructions are handled similarly. Heap corruption can be detected by the memory manager if you enable its Full Debug Mode, and it will raise an exception (and write you out a log file full of debug information) if it detects any corruption.
Again, this is the sort of thing that your language ought to be handling for you, and I really don't see much use for it unless someone is actually building SDL projects in C itself.
From: Nathaniel J Fries <nfries88 at yahoo.com>
To: sdl at lists.libsdl.org
Sent: Thursday, March 28, 2013 1:49 PM
Subject: Re: [SDL] SDL_crash -- fatal error catching with user callback
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.
SDL mailing list
SDL at lists.libsdl.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL