PHP/Apache crashing on script (Segmentation fault (11)
I'm running a PHP script (with some includes) on localhost that keeps crashing before the end.
Error reporting is on. Opera, Safari and Firefox return an empty screen. But Chrome returns:
Unable to load the webpage because the server sent no data. Error code: ERR_EMPTY_RESPONSE
Apache logs returns:
[Sun Dec 15 19:29:23 2013] [notice] child pid 34267 exit signal Segmentation fault (11)
Was using PHP 5.5.6 when I encountered the problem for the first time After downgrading to PHP 5.4.21 the problem still exists.
The problem is not inside the script. Randomly commenting out a couple of 50 lines of code solves the problem. Making me wonder if my script might be to long for execution.
Does anyone has any suggestions on how I can resolve this problem?
Problem doesn't only appears on the localhost but also on my webserver running on CentOs 6.4 and PHP 5.3.3 giving the same error on Apache.
[Sun Dec 15 23:15:10 2013] [notice] child pid 18409 exit signal Segmentation fault (11)
Running php from the command line gives:
$ php index.php Fatal error: Call to undefined function mcrypt_create_iv() in Encrypt.class.php on line 135
After placing a comment before line 135 on Encrypt.class.php
$ php index.php Segmentation fault: 11
After running the index on command line with strace (strace php index.php) I found the problem at one of the queries.
After some more debugging (using PDO instead of my own class) I found out that the problem was setting my own PDO option "ATTR_PERSISTENT => true". Disabling this option solved my problem.
Persisten option of PDO broke my performance sadly enough.
Found the solution with strace: After running the index on command line with strace (strace php index.php) I found the problem at one of the queries.
After separating the query i replaced my class with default PDO. Adding options of my class till it was broken again: After some more debugging (using PDO instead of my own class) I found out that the problem was setting my own PDO option "ATTR_PERSISTENT => true". Disabling this option solved my problem.