This document was hosted from my directory for many years. Latest information:

a couple of modules that use the exception hook added in Apache 2.0.49

These can be used in conjunction or individually or simply cut up into pieces as you see fit. They should work fine on Apache 2.0 >= 2.0.49, but mod_whatkilledus currently needs the test_char.h file from an Apache 2.1-dev build.

You must specify the --enable-exception-hook configure option and also add EnableExceptionHook on to your httpd conf file in order to allow modules to run after fatal exceptions (synchronous signals on Unix).

mod_backtrace is limited to Linux and FreeBSD at present, unfortunately, but mod_whatkilledus has been used on a variety of Unix-like systems.


inspired by an ugly problem in 1.3 where we couldn't get a core dump and had no idea what type of request led to the segfault... only thing I could think to do was give them a module that wrote a log message near the beginning of the request to give all sorts of information about the request (url, ssl?, virtual host, etc.) in hopes of finding a pattern... but of course this filled up a big file

mod_whatkilledus keeps a little bit of state on each active connection, which allows it to know what a thread was handling in case the thread segfaults. If that happens, it writes a report to the error log

Here is an example report:

[Tue Mar 16 19:11:44 2004] pid 29412 mod_whatkilledus sig 11 crash
[Tue Mar 16 19:11:44 2004] pid 29412 mod_whatkilledus active connection:> (conn_rec 434b90)
[Tue Mar 16 19:11:44 2004] pid 29412 mod_whatkilledus active request (request_rec 438b48):
GET /silly?fn=sigsegv HTTP/1.1||
User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv%3a1.5)
[Tue Mar 16 19:11:44 2004] pid 29412 mod_whatkilledus end of report

It might be interesting to know what other threads in the process were doing too. They probably didn't cause the problem, but the server crashed in the middle of that activity, which could conceivably have future repercussions. Hopefully a future revision of mod_whatkilledus will have a configuration directive that specifies that information for all threads should be logged, not just information for the thread that crashed.


here's another trick for situations where you can't get a core dump and/or can't get a backtrace

mod_backtrace is a module (currently just for Linux and FreeBSD) which uses system functions to format a backtrace to show what code did the dirty deed. Unfortunately the exact format and unfortunately the usefulness varies among glibc versions. Here is how it can look on Redhat Advanced Server 2.1:

[Tue Mar 16 19:11:44 2004] pid 29412 mod_backtrace backtrace for sig 11 (thread "pid" 29438)
[Tue Mar 16 19:11:44 2004] pid 29412 mod_backtrace main() is at 8071048
[Tue Mar 16 19:11:44 2004] pid 29412 mod_backtrace end of backtrace

I've seen just a series of hex addresses on an older SuSE distro on zSeries. The address of main() is logged too, so enterprising individuals will be able to make sense of those hex addresses by using "nm -n httpd" to display httpd symbols. For functions which are part of httpd, the hex addresses in the backtrace will correspond to instructions within the range of a function displayed by nm. (Enterprising zSeries folks will of course need to ignore the high-order bit of the addresses in the backtrace.)

I don't know how DSOs are laid out in storage, and mod_backtrace doesn't display any known addresses for the DSOs to give a hint. Maybe mod_backtrace needs to have an option to walk through the loaded DSOs and spit out the module name and some associated address to make this straightforward.