Php Core Dump

What is core dump?

Linux use to terminate the process if certain signals(signal 7 ) is to cause a process to terminate and produce a core dump file. The core dumps are store as a disk file (named as in the present working directory or the document root directory which helps the administrator to analysis image of the process’s memory at the time of termination. For example when a program or process try to allocate more memory than allocated, trying to bypass security restrictions etc. A process can set its soft RLIMIT_CORE resource limit to place an upper limit on the size of the core dump file that will be produced if it receives a “core dump” signal.

You can core dump file pattern by changing the value in /proc/sys/kernel/core_pattern more on Linux Core dump

Core dumping with php

Php dumps are more commonly seen if you are administrate a web hosting server. Since the use to bind/link with many other packages like zend, ioncube, settings on php.ini etc you need to check each and every setting or by enabling/disabling the lines in the php.ini file to check what is causing the core dump. Say for example if you have an incorrect version of Zend on the latest php version, you need to disable the zend config lines and upgrade it to the latest/right version that support your current php version to get ride of this error.

Analyzing core dump

Linux comes with a great tool called GDB (Gnu Project Debugger) which helps to analysis what is causing the core dumps. To install gdb on your CentOS/Fedora. Try

  • Yum install gdb

And it will install the gdb package alone will all the dependency. To analysis the core dump try using.

  • gdb app <core.file>

For example in my case a core dump was caused by a php -v due to incorrect memory_limit setting in the php.ini file.

Php Core dump

Core was generated by `php -v’.

Program terminated with signal 11, Segmentation fault.

To troubleshoot the problem. try moving/renaming the default php.ini file

  • mv /etc/php.ini /etc/php.ini.b

Then try the command once again and see if that displays the php version. If the problem still occurs after moving the php.ini file then it could be due to some corruption with linked libraries, you need to either reinstall or recompile the php once again to fix the problem you can also try ldd /path/php and make sure that all the linked files are working.

Core dump on Apache process

Core dumps may also occur with apache process. For example

Apache Core dump

Core was generated by `/usr/local/apache/bin/httpd -k start -DSSL’.

Program terminated with signal 11, Segmentation fault.
In this case you may need to disable and check the modules to find and what is causing the core dumps.