Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save msztorc/5fb48b26167975fa935a57a393a62373 to your computer and use it in GitHub Desktop.
Save msztorc/5fb48b26167975fa935a57a393a62373 to your computer and use it in GitHub Desktop.
Core dumps and gdb backtrace for php-fpm and apache

#PHP Apache CORE DUMP - GDB backtrace

Open httpd.conf: vi httpd.conf

Add following line main config section: CoreDumpDirectory /tmp/apache2-gdb-dump

Unlimited core dump size, In terminal add below ulimit -c unlimited

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

Now you should see core dumps in /tmp/apache2-gdb-dump directory: ls /tmp/apache2-gdb-dump

Install GDB yum install gdb or apt-get install gdb or .....check online

Reading the core dumps

```gdb $program-path $coredump-path or gdb -c <core_file> `which <program-path>`
Example:
    gdb /usr/sbin/php-fpm /tmp/apache2-gdb-dump```

with in GDB

   * set disassembly-flavor intel
   * set logging on
   * bt full
   * info reg
   * disassemble
   * info shared
   * Info threads

#PHP-FPM CORE DUMP - GDB backtrace

Check if core dump is enabled or not

    ls /tmp/coredump*

If not, Enable core dumps

  1. Create core dump file and point to the kernel core_pattern
    echo '/tmp/coredump-%e.%p' > /proc/sys/kernel/core_pattern
  1. Open your php-fpm pool configuration and add
    rlimit_core = unlimited

Unlimited core dump size, In terminal add below

    ulimit -c unlimited

Install GDB yum install gdb or apt-get install gdb or .....check online

Reading the core dumps

    ```gdb $program-path $coredump-path or gdb -c <core_file> `which <program-path>`
    Example:
        gdb /usr/sbin/php-fpm /tmp/coredump-php-fpm.2393```

with in GDB

   * set disassembly-flavor intel
   * set logging on
   * bt full
   * info reg
   * disassemble
   * info shared
   * Info threads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment