8

I am having problems with my 14.10 Ubuntu Server. Upon performing certain actions my apache2 restarts with a segmentation fault error. In order to debug this issue I would like to create a core dump. I have done the following:

  • added CoreDumpDirectory /tmp/apache-coredumps to the config file
  • Run ulimit -c unlimited
  • Run apt-get install apache2-dbg php5-dbg
  • restarted apache and caused the error. The log claims there may be a core dump in the directory, however it is empty.

I also tried to use gdb directly on the executable of apache2, but apache won't start unless started through apachectl or service apache2 start.

How can I get a core dump to debug my issue OR how can I attach gdb directly to apache?

Andreas Hartmann
  • 2,563
  • 7
  • 29
  • 46
  • For the former, look here: http://serverfault.com/questions/470407/how-to-get-a-core-dump-from-apache-when-segfaulting for the latter, here: http://httpd.apache.org/dev/debugging.html#gdb – Elder Geek Apr 22 '15 at 17:06
  • Unfortunately, this didn't work. I tried setting the permissions as suggested in the first link, however still no core is dumped. I already knew the second link. It doesn't really answer my question in an ubuntu specific manner (Ubuntu doesn't have an httpd executable, and calling apache2 directly doesn't work for previously mentioned reasons). – Andreas Hartmann Apr 22 '15 at 17:42
  • Is the coredump in /tmp instead perhaps? – Elder Geek Apr 22 '15 at 17:58
  • I specified the core dump to be placed in a different folder, so it's not in /tmp. – Andreas Hartmann Apr 22 '15 at 18:14
  • I don't want to use apport, I want to examine my problem locally and not report an error, because it's probably not an apache bug. – Andreas Hartmann Apr 22 '15 at 18:15
  • This doesn't really help. Keep in mind I'm on Ubuntu server, only connected via ssh. Apport seems to be a GUI to create core dumps. – Andreas Hartmann Apr 23 '15 at 16:38
  • No problem. It's a hosted virtual server so no point in ram testing. Segfaults often occur when there are incompatibilities for example with php. – Andreas Hartmann Apr 23 '15 at 16:55
  • Did you see this? http://httpd.apache.org/dev/debugging.html – Elder Geek Apr 23 '15 at 17:02
  • possibly related: ulimit -c unlimited only effects your current shell session. You can check limits of httpd by looking in /proc. `cat /proc/$(pidof httpd)/limits` – Jay _silly_evarlast_ Wren Apr 27 '15 at 17:38

1 Answers1

4

ulimit -c unlimited only effects your current shell.

You can confirm this by looking at output cat /proc/$(pidof -s apache2).

I added ulimit -c unlimited to /etc/default/apache2 and now cat /proc/$(pidof -s apache2)/limits includes

Max core file size        unlimited            unlimited            bytes
  • I tried this but it still didn't get Apache (12 LTS) to dump core. Any thoughts? – Josip Rodin Nov 13 '15 at 22:03
  • Found the answer - apport was enabled in `/etc/default/apport`, and it changed the kernel core dump pattern to suit itself. See http://serverfault.com/questions/470407/how-to-get-a-core-dump-from-apache-when-segfaulting – Josip Rodin Nov 15 '15 at 16:27
  • echo '/tmp/apache-coredumps/core-%e.%p' > /proc/sys/kernel/core_pattern – Rudger Jun 27 '16 at 13:35