Apache httpd core dump instructions

I sometimes run into bugs or issues with Apache HTTPD that require having the server create a core dump file. For example, today I noticed my error_log showing this:

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

I found a helpful page on the Apache website with instructions. They suggest that a core dump will be generated simply by adding the following to your httpd.conf file and restarting:

CoreDumpDirectory /tmp

After adding that setting and restarting, Apache still would not dump core. Same segmentation fault, no core.

After significantly more searching, I discovered that there are a few important additional settings in Linux before httpd will dump core. First, lift process limits on core dump size.

# ulimit -c unlimited

Next, direct the kernel as to whether core dump files are produced for SUID or otherwise protected/tainted binaries.

# sysctl -w fs.suid_dumpable=2

Finally, and here's the kicker that was really difficult to find in other articles on this subject: set the core dump name schema to match the directory in the httpd.conf file.

# sysctl -w kernel.core_pattern=/tmp

This last step was critical. At least in Fedora, this was set to / by default, which is the root of the filesystem. Since httpd drops privileges after starting, it has no write permissions on the / directory so it won't dump core.

At this point you should be able to collect your core dump and run gdb to grab a backtrace of what crashed.

I hope you found this helpful. Quesitons and comments are welcome below.

Add new comment