Crash and burn: Writing Linux application fault handlers

Gilad Ben-Yossef June 30th, 2008

Complementing the standard Linux fault handler (”Segmentation fault. Core dumped.”) with a custom handler that reports the crashing program state without a debugger is a useful endeavor in many situations. Unfortunately, writing such a fault handler correctly can be surprisingly hard and requires certain amount of black magic.

In this tutorial we will demonstrate how to write such a handler, covering such topics as: getting program symbolic stack trace and registers and reporting them safely, the care and feeding of async signal POSIX handler functions, how to avoid implicit memory allocations and how to test for them, how to handle multi-threaded faults, the black magic involved with how Linux handles signal handlers, the unfortunate effect this has on obtaining a correct stack trace in case of a fault and how to overcome this limitation.

Here are the Crash and Burn code examples.

One Response to “Crash and burn: Writing Linux application fault handlers”

  1. [...] just added a brand new tutorial to the lectures section on the site, entitled: “Crash and burn: Writing Linux application fault handlers“. Check out the full description, slides and example code on the lecture [...]

Trackback URI | Comments RSS

Leave a Reply