Hmm, looks like some versions of PHP, including the one running on outputthis.org, crash if you call a function defined inside a switch statement. Oops!
BTW, if you find that your script is crashing PHP (i.e. your browser gives an error, the server drops the HTTP connection after receiving the headers, and you get an error in /var/log/apache/error.log like [notice] child pid 2706 exit signal Segmentation fault (11)
), here’s how you figure out what’s going wrong - or at least get something to Google.
- Step 1 - enable core dumping in Apache
Edit /etc/apache/conf/httpd.conf (it might be at /etc/httpd/conf/httpd.conf) and set the CoreDumpDirectory
option to a directory that Apache can write to. I created a new directory:
mkdir /var/run/httpd-core
chown apache.apache /var/run/httpd-core
… then put this line in httpd.conf:
CoreDumpDirectory /var/run/httpd-core
Now tell Apache to reload config:
apachectl graceful
- Step 2 - trigger the error
Browse to the page or do whatever you need to do to cause PHP to crash Apache.
- Step 3 - find out what happened
Now you should have a file called something like core.1234
in /var/run/httpd-core
. This file contains lots of info on what was going on at the time of the crash. You can inspect it with gdb:
cd /var/run/httpd-core
gdb /usr/sbin/httpd
core core.1234
bt
Now you will be given a stack dump. Cut and paste the function name and address from the first line (in my case “0x0000002a9a6ae417 in zend_switch_free_handler
”) into Google. If that doesn’t return anything, try searching for the function name and the word ‘crash’, i.e. google for zend_switch_free_handler crash
.
Now look through the first few results, and if you’re lucky, you’ll get a page describing some odd coding practise that PHP doesn’t handle well. In my case it was this one - “function defined in switch, carshes”.
Good luck!