php5 fpm: how do you generate core dump from segfault?

Under load, my PHP5-fpm (on 32bit ubuntu 10.10) produces segfaults like the following:

kernel: [4881937.884863] php5-fpm[2638]: segfault at 4204eb41 ip 0832d235 sp bfcea5e0 error 4 in php5-fpm[8048000+70d000]

How do I make it so these segfaults produce a core dump so that I can inspect the call stack to figure out where the segfault is coming from?

Where do the core dumps go once they are produced?


Solution 1:

You can enable core dump with:

su -
echo '/tmp/core-%e.%p' > /proc/sys/kernel/core_pattern
echo 0 > /proc/sys/kernel/core_uses_pid
ulimit -c unlimited

Set the rlimit_core directive in /etc/php-fpm.d/www.conf to unlimited:

rlimit_core = unlimited