Skip to content

Instantly share code, notes, and snippets.

@guilhermeblanco
Created June 8, 2016 15:59
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save guilhermeblanco/894d3288e17d4cd11f19f58d9c0fd253 to your computer and use it in GitHub Desktop.
Save guilhermeblanco/894d3288e17d4cd11f19f58d9c0fd253 to your computer and use it in GitHub Desktop.
Debugging PHP-FPM segfaults

Assuming PHP is compiled with debug enabled.

$ gdb /usr/sbin/php-fpm

Then:

r --nodaemonize --fpm-config /etc/php7/fpm/php-fpm.conf

Make the request... then collect the stacktrace:

bt
@guilhermeblanco
Copy link
Author

guilhermeblanco commented Jun 15, 2016

Alternative in a debug build.

  • Those make the error message a bit more verbose by stating which emalloc call caused this.
    Probably one can receive more info by attaching gdb (or another debugger) to the PHP process:
$ gdb -p 1234   # 1234 is the PID of a PHP process
(gdb) source /path/to/php-src/.gdbinit
(gdb) break zend_mm_safe_error
(gdb) run

now hit PHP a few times

(gdb) bt
[dumps system stack trace]
(gdb) zbacktrace
[dumps PHP-level stack trace, gdb macro defined in gdbinit loaded above]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment