QA
Senior LevelPHP 8+

How do you debug PHP-FPM segmentation faults (SIGSEGV) in production using gdb and Linux core dumps?

❓ Interview Prompt: Explain debugging C-level PHP segmentation faults (SIGSEGV), enabling Linux core dumps, GNU Debugger (gdb), and strace syscall inspection.

When a PHP-FPM worker process crashes with a Segmentation Fault (SIGSEGV), PHP cannot write standard error logs or stack traces because the C runtime process crashed at the OS kernel level.

Debugging Workflow:

1
Enable Linux Core Dumps: Set 'ulimit -c unlimited' and configure '/proc/sys/kernel/core_pattern = /tmp/core.%e.%p'.
2
Inspect Core File in GDB: Open the core dump file in GNU Debugger:

'gdb /usr/sbin/php-fpm /tmp/core.php-fpm.4096'

3
Execute Backtrace ('bt'): Run the 'bt' command in GDB to inspect the exact C function call stack and identify whether the crash originated in OPcache, ext-curl, or a third-party C extension!

Code Implementation Example

bash
# Linux commands to capture and inspect PHP-FPM segmentation fault core dump
ulimit -c unlimited

# Inspect core dump file in GNU Debugger (GDB)
gdb /usr/sbin/php-fpm8.3 /tmp/core.php-fpm.4096

# Inside GDB prompt:
(gdb) bt
# Displays C call stack backtrace showing exact crashing C extension line!
💡Debugging PHP-FPM segmentation faults using GDB backtrace analysis.
🎯 Interview Key Takeaway

Enable Linux core dumps and run GDB backtrace (bt) against the PHP-FPM binary to pinpoint the C extension causing segmentation faults.

#Segmentation Fault#GDB#PHP-FPM#Debugging#Senior
Back to all PHP 8+ Questions→

More PHP 8+ Interview Questions

Beginner LevelPHP

What is PHP and how does its shared-nothing request lifecycle work?

Beginner LevelPHP

What is the difference between echo and print in PHP?

Beginner LevelPHP

What is the difference between isset(), empty(), and is_null() in PHP?