How to trace Apache segmentation fault?

Refers to:

  • Plesk for Linux

Created:

2016-11-16 12:44:25 UTC

Modified:

2017-01-22 22:03:07 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to trace Apache segmentation fault?

Symptoms

Webpages return an HTTP error 500 in the main apache log usually it located in /var/log/httpd/error_log or /var/log/apache2/error_log. Every time when I visit affected page in the log file I see strings with 'Segmentation fault'

Cause

Some extension or interoperability with OS module causing crash.

Resolution

  1. Find a partition having a free space enough to store several memory dumps. In this example, it will be root '/' partition.

  2. Modify Apache startup script:

    • For Debian-based add ulimit -c unlimited in /etc/init.d/apache2, in do_start() section.

    • For RHEL-based systems add LimitCORE=infinity in [Service] section of the unit file, e.g. for CentOS 7:

      [root@server ~]# cat /etc/systemd/system/multi-user.target.wants/httpd.service
      ...
      [Service]
      Type=notify
      ...
      LimitCORE=infinity
  3. Create a folder where core dumps will be stored:
    mkdir -p /tmp/coredumps
    chmod a+w /tmp/coredumps
  4. Modify /proc/sys/kernel/core_pattern to relative path

    echo /tmp/coredumps/core-%e-%s-%u-%g-%p-%t > /proc/sys/kernel/core_pattern

    Note: If, by some reason, core_pattern can not be modified it will be saved in a directory from where application started.

  5. Add CoreDumpDirectory directive in httpd.conf and specify location for core dump file:

    [root@server ~]# grep "CoreDumpDirectory" /etc/httpd/conf/httpd.conf
    CoreDumpDirectory /tmp/coredumps
  6. Restart Apache service

    Note: in order to test configuration you can send kill -SIGSEGV to Apache child and check whether dump file has been created.

  7. Open affected website/page in a browser and wait for 500 error.
  8. Ensure that core dump have been created in /tmp/coredumps/ directory.

    Note: that if abrtd daemon is running, it will prevent coredump files creation.

  9. Remove ulimit -c unlimited from the init script and restart Apache.

  10. To analyse the core dump, pass the core dump filename on the gdb utility:

    gdb /usr/sbin/apache2 /tmp/coredumps/core-php-cgi-11-10007-1004-13087-1482920422
     /path/to/corefile
  11. Execute bt command at the gdb prompt to get backtrace and analyse output:

    (gdb) bt

Additional information

http://httpd.apache.org/dev/debugging.html

Have more questions? Submit a request
Please sign in to leave a comment.