2 minutes
Enabling Apache HTTPD2 Core Dumps on Debian
Background
I ran into numerous solutions to enable Apache HTTPD2 core dumps under Debian 9. With some trial and error, this is how I got apache2 to make core dumps as a result of a segfault occuring.
Note: In some situations, enabling core dumps on a production server can present a security risk.
Breakdown
Prerequisites
We need to install systemd-coredump
to configure and view the dumps. Additionally, on the system where the dumps are analysed, we will need both the GNU Project Debugger (GDB) and the apache2 debugging symbols.
sudo apt install -y systemd-coredump gdb apache2-dbg
The apache2-dbg
package is not available on Debian 10. You might need to recompile apache2 and then install the resultant apache2-dbg .deb
file with dpkg.
Process
Step 1
Add the CoreDumpDirectory
directive into the apache2 (httpd) configuration:
echo "CoreDumpDirectory /tmp" | \
sudo tee /etc/apache2/conf-available/core-dumps.conf
Note that the CoreDumpDirectory
value appears to be ignored in so far as where apache2 will store the core dumps. The specified directory however, must exist otherwise apache2 will not start.
Step 2
Enable the new configuration:
sudo a2enconf core-dumps
Step 3
Restart apache2:
sudo systemctl restart apache2
Result
Now upon segfault, apache2 will log:
[Tue Jul 27 18:00:58 2021] [notice] [pid 2572] mpm_unix.c(430): [client AH00051: child pid 2574 exit signal Segmentation fault (11), possible core dump in /tmp
Accessing Apache HTTPD2 Core Dumps
Core dumps will be saved to /var/lib/systemd/coredump
.
Use coredumpctl list
to list the dumps and, for example, coredumpctl gdb /usr/sbin/apache2
to launch GDB with the most recent apache2 dump.
Additional Notes
- No need to apply ulimit tweaks (core dump size limits)
- No need to change
/etc/apache2/envvars
,/usr/sbin/apache2ctl
or any init scripts - No need to edit
/etc/security/limits.conf
- Tested with Debian apache2 2.4.25-3+deb9u10