Debug Coredump of Swoole

Notice: ext-swoole is supported until v4.7.1, use ext-openswoole >= v4.7.1. Latest version: pecl install openswoole-4.10.0

If you have seen segment falt errors of your Swoole application, please follow the following steps to generate a call stack report.

To see the call stack related to Swoole, you have to add --enable-debug when compiling Swoole.

1. Install gdb and enable coredump

ulimit -c unlimited

2. Run your application and generate core-dump file

Depends on your OS, the core dump file may be located at different folders: /tmp or /cores.

3. View the info in the core-dump file:

gdb php core 

gdb php /tmp/core.xxxx

4. View the call stack

f 1
f 0

How to enable coredump on Linux

rm -rf /tmp/core.*
ulimit -c unlimited
echo '1' > /proc/sys/kernel/core_pipe_limit
echo '1' > /proc/sys/kernel/core_uses_pid
echo '/tmp/core'> /proc/sys/kernel/core_pattern

How to enable coredump on MacOS

sudo mkdir /cores 
sudo chown root:admin /cores 
sudo chmod 1775 /cores
sudo chmod o+w /cores
ulimit -c unlimited