It’s sometimes reasonable to debug the php modules in apache itsself, but it’s not trivial tracking the right process executing the php handler. Therefore reduce the number of forked childs to 1 and restart apache2.

# vim /etc/apache2/apache2.conf

StartServers 1
MinSpareServers 1
MaxSpareServers 1

# service apache2 restart

Look for the child process and attach your gdb to it.

ps aux | grep apache2

gdb
attach 

Continue the process and go play in your web browser, triggering the segfault.

(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00007fb78804e3e0 in gc_remove_zval_from_buffer () from /usr/lib/apache2/modules/libphp5.so
(gdb) bt
#0  0x00007fb78804e3e0 in gc_remove_zval_from_buffer () from /usr/lib/apache2/modules/libphp5.so
#1  0x00007fb7880a8308 in ?? () from /usr/lib/apache2/modules/libphp5.so
#2  0x00007fb788059678 in execute_ex () from /usr/lib/apache2/modules/libphp5.so
#3  0x00007fb7880314b0 in zend_execute_scripts () from /usr/lib/apache2/modules/libphp5.so
#4  0x00007fb787fd17e5 in php_execute_script () from /usr/lib/apache2/modules/libphp5.so
#5  0x00007fb7880e161a in ?? () from /usr/lib/apache2/modules/libphp5.so
#6  0x00007fb78c783350 in ap_run_handler ()
#7  0x00007fb78c7838a9 in ap_invoke_handler ()
#8  0x00007fb78c7986fa in ap_process_async_request ()
#9  0x00007fb78c7989e4 in ap_process_request ()
#10 0x00007fb78c795492 in ?? ()
#11 0x00007fb78c78c420 in ap_run_process_connection ()
#12 0x00007fb7889c2767 in ?? () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#13 0x00007fb7889c29a6 in ?? () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#14 0x00007fb7889c2a06 in ?? () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#15 0x00007fb7889c36f0 in ?? () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#16 0x00007fb78c76a5ee in ap_run_mpm ()
#17 0x00007fb78c763df6 in main ()

In short, I’ve had triggered that bug on my Debian Jessie system with PHP 5.5 while executing Icinga Web (stable or dev version, does not matter). A recent php update fixed the issue. I could’ve gone more into detail with unstripped binaries but who got time for that anyways 😉

%d bloggers like this: