Enabling core dumps on Apache2.2 on Debian

It was quite an adventure today,figuring out how to get a segfaulting Apache to give me core dumps to analyze on Debian Squeeze. What SHOULD have been easy…wasn’t. Here’s what all you must do:

First of all,you’ll need to set ulimit -c unlimited in your /etc/init.d/apache2 script’s start section.

case $1 in
start)
log_daemon_msg "Starting web server" "apache2"
# set ulimit for debugging
# ulimit -c unlimited

Now make a directory for core dumps –mkdir /tmp/apache2-dumps ;chmod 777 /tmp/apache2-dumps –then you’ll need to apt-get install apache2-dbg libapr1-dbg libaprutil1-dbg

And,the current (Debian Squeeze,in May 2012) version of Debian does not have PIE support in the default gdb,so you’ll need to install gdb from backports. So,add deb http://backports.debian.org/debian-backports squeeze-backports main to /etc/apt/sources.list,then apt-get update &&apt-get install -t squeeze-backports gdb

Now add “CoreDumpDirectory /tmp/apache2″to /etc/apache2/apache2.conf (or its own file in conf.d,whatever),then /etc/init.d/apache2 stop ;/etc/init.d/apache2 start

And once you start getting segfaults,you’ll get a core in /tmp/apache2-dumps/core.

Finally,now that you have your core,you can gdb apache2 /tmp/apache2-dumps/core,bt full,and debug to your heart’s content. WHEW.

Leave a Reply

  

  

  

You can use these HTML tags

<a href=""title=""><abbr title=""><acronym title=""><b><blockquote cite=""><cite><code><del datetime=""><em><i><q cite=""><strike><strong>

I'm not a spammer,I promise!This plugin created by memory cards