Configure an Apache web server for core dump on segmentation faults

Recently I have noticed that my Apache error log file shows it is generating segmentation faults. After doing little research I came to know that there is not simple solution to find of causes of this problem. I got an error that read as follows:

[Mon May 8 11:20:09 2006] [notice] Apache/2 (WebAppBETA) child pid 1256 exit signal Segmentation fault (11)
[Mon May 8 11:23:12 2006] [notice] Apache/2 (WebAppBETA) child pid 1301 exit signal Segmentation fault (11)

The problem is that our application development team has hacked (aka modified source code) Apache 2.0 source tree for application my company developing. To get rid of this problem I was asked to configure a Linux system so that Apache can dump core files on segmentation faults.

Apache Core Dump

Apache supports CoreDumpDirectory directive. This controls the directory to which Apache attempts to switch before dumping core. So all I need to do is put line as follows in httpd.conf:

Open httpd.conf:
# vi httpd.conf
Add following line main config section:
CoreDumpDirectory /tmp/apache2-gdb-dump
Create a directory /tmp/apache2-gdb-dump:
# mkdir -p /tmp/apache2-gdb-dump
Set permission:
# chown httpd:appserver /tmp/apache2-gdb-dump
# chmod 0777 /tmp/apache2-gdb-dump

Please note that we are using httpd user and group appserver. Please replace it with your actual Apache user:group combination.

And restart the Apache web server:
# /etc/init.d/httpd restart
OR kill Apache PID:
# kill -11 14658
Now you should see core dumps in /tmp/apache2-gdb-dump directory:
# ls /tmp/apache2-gdb-dump

How do I read the core dump files created by Apache on Linux systems?

Well I am not a developer but they are using gdb and other techniques to analyses the core dumps. Read man page of gdb for more information.

I hope that I will get a new patched version of Apache by next week. Another interesting fact I noticed that you need to configure Core Dumps on Linux only. We are also using FreeBSD for testing and it write core dump in the ServerRoot directory.

If Apache starts as root and switches to another user, the Linux kernel disables core dumps even if the directory is writable for the process. Apache (2.0.46 and later) enables core dumps on Linux 2.4 and beyond, but only if you explicitly configure a CoreDumpDirectory. 🙂

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Shinto Jan 6, 2015 @ 13:46

    What steps will reproduce the problem?
    1. while executing bafprp file using python program getting an error “Segmentation fault (core dumped)”

    What is the expected output? What do you see instead?
    Output should be a .csv file which should be having few selected fields which is passed while executing

    ### python code used for execution code
    >>> command=Pri_exe_file_path+’ -rcsv -prfields:’+SelectFields+’ -prfilename:’+ output_csv_file + ” ” + filename + ”
    >>> commands.getoutput(command)

    What version of the product are you using? On what operating system?

    Linux BDMAGFPC005 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

  • eMPee584 Apr 18, 2010 @ 20:01

    yup, the
    ulimit -c unlimited
    followed by an apache restart is necessary on many systems. Also, you will very likely have to install debug symbols for your distro (aptitude install apache2-dbg php5-dbg on debian) to get any meaning out of the core file. After doing that, examine it with
    gdb apache2 –core /path/to/corefile
    a ‘bt’ will give you a backtrace which might tell you where the culprit is.

  • Erik Jan 5, 2009 @ 22:48

    You should also note that people should add the following to their apache init script:

    ulimit -c unlimited

    My systems have a default core size of 0, which effectively disables coredumps.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.