9

[SOLVED]

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?

UPDATE:

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)

UPDATE2:

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

UPDATE3: (Solution)

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.

5
  • 1
    Try running the script from the command line. If it throws a segmentation fault, your version of PHP needs to be re-installed. If it runs just fine from the command line, then you should probably re-install Apache. What line of code is throwing this error exactly. Do you know? Commented Dec 15, 2013 at 19:55
  • @MisterMelancholy running the file on the command line gives an "Fatal error" Call to undefined function mcrypt_create_iv() in Encrypt.class.php on line 135. This function works fine in the browser. No specific line gives the error. Commented Dec 15, 2013 at 20:02
  • When you downgraded PHP, are you sure all the extension .so files got downgraded too? Maybe you are using a PHP 5.5 mcrypt extension with PHP 5.4 or 5.3 (and not including it at all in whatever php.ini your CLI reads from) Commented Dec 15, 2013 at 21:04
  • Downgrade went successfully. Upgraded through macports and returned to default PHP on osx 10.9 changing the path in httpd.conf. mcrypt extension also works fine on my webserver on PHP 5.3.3 Commented Dec 15, 2013 at 21:10
  • 2
    If you've solved the problem, please can you post your solution as a separate answer and then accept it? That makes it much easier for people to see what the solution was, as well as removing the question from the 'unanswered questions' queue. Commented May 24, 2014 at 17:29

1 Answer 1

5

UPDATE3: (Solution)

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.