Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need some help with an error I have not encountered before and can't seem to find anywhere.

In a PHP mvc framework (just from a tutorial) I have the following:

// Initiate the class
$className = 'Controller_' . ucfirst($controller);
if (class_exists($className)) {
 $controller = new $className($this->registry);

$className is showing the correct class name (case is also correct). But when I run it I get this in the apache error log (no php error)

[Wed Mar 31 10:34:12 2010] [notice] child pid 987 exit signal Segmentation fault (11)

Process id is different on every call. I am running PHP 5.3.0 on os x 10.6. This site seems to work on 5.2.11 on another Mac. Not really sure where to go next to debug it. I guess it could be an apache setting as much as a php bug or a problem with the code... any suggestions on where to look next?

The error does not appear on commenting out that code. I also have about 15 other php sites running with no problems. Including others using the same base mvc framework

share|improve this question

migrated from Mar 31 '10 at 11:23

This question came from our site for professional and enthusiast programmers.

Since it's a segfault there doesn't have to be something wrong with the script but definitely with the php build. A script should never be able to crahs the php instance (so hard that the os has to terminate the process). – VolkerK Mar 31 '10 at 10:52
Do you get the segfault if you comment out that line of code? (i.e. is it definitely these 4 lines of code causing the problem?) – Andy Shellam Mar 31 '10 at 10:52
I'd assume this to be caused either by faulty hardware or by any of the modules loaded in Apache. Voting to move to serverfault. – Gordon Mar 31 '10 at 10:54
Why has a programming question been migrated away from SO? – John Gardeniers Sep 24 '10 at 9:32
Because the error is not from the code, but from the php built. – Anarko_Bizounours Jun 21 '11 at 15:09
up vote 2 down vote accepted

I remember having the exact same issue. If I remember correctly the problem was recursive instantiation, i.e. PHP ran out of memory, which caused the segmentation fault. Check that the instantiation of $className does not go around in circles.

share|improve this answer

Try this:

// Initiate the class
$className = 'Controller_' . ucfirst($controller);
if (class_exists($className)) {
     // construct the code string and evaluate it.
     $code='$controller = new ' . $className . '($this->registry);';
share|improve this answer

I think you problem is from your own mac. If you did try the website from another computer and did not get the error, then that mean you'll need to reinstall you php package. Something went wrong at some time with your php built (maybe an update, or an link destroyed because of new installation...)

Hope this will help you.

share|improve this answer

Try using curly braces around your class name variable. See below in the $controller assignment line.

$className = 'Controller_' . ucfirst($controller);
if (class_exists($className)) {
 $controller = new ${$className}($this->registry);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.