Created
January 20, 2011 00:02
-
-
Save landonf/787146 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Plausible CrashReporter now provides support for executing your own code in the context of the | |
crash reporter's signal handler, after the crash report has been written to disk. This was a | |
regularly requested feature, and provides a convenient point for performing application finalization. | |
However, there is an important caveat to be aware to when writing code intended for execution inside | |
of a signal handler -- specifically, your code must be async-safe. | |
Program Flow and Signal Handlers | |
When the signal handler is called, the normal flow of the program is interrupted, and your program is | |
an entirely unknown state. Locks may be held, the heap may be corrupt (or in the process of being updated), | |
and your signal handler may invoke a function that was being executed at the time of the signal. This may | |
result in deadlocks, data corruption, and program termination. | |
Async-Safe Functions | |
A subset of functions are defined to be async-safe by the OS, and are safely callable from within a | |
signal handler. If you do implement a custom post-crash handler, it must be async-safe. A table of | |
POSIX-defined async-safe functions and additional information is available from the CERT programming | |
guide - SIG30-C: | |
https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment