Apache segmentation fault debugging

Sometimes you will see lines like this in the Apache error log:

[notice] child pid 5 exit signal Segmentation fault (11)

This means for some reason the child thread/fork has segfaulted when trying to process the request.

By default apache won’t give you any more info than this. To get core dumps you will need to do the following.

  1. Enable system coredumps for the apache user. In /etc/security/limits.conf ensure the following line is present:
apache soft core 10000
  1. Tell apache what directory to put dumps into, do this with the following config line:
CoreDumpDirectory /var/apache/coredumps/
  1. Ensure the dump directory is writeable by the apache user (if not then you will get no dumps!).

  2. Restart apache and wait for a segfault.

Now if you look in your specified CoreDumpDirectory you should see a number of .dump files.

To debug these you will need to understand system calls and have some general debugging experience when it comes to executables.

An example of how to load up the core dump into a debugger (gdb) is as follows:

gdb /usr/sbin/httpd -c /var/apache/coredumps/somefile.dump

Some genreal tips on how to use a debugger for looking at Apache dumps can be found on their website.

Comments