views:

39

answers:

1

UPDATED INFO:

OS Windows 7 32bit Apache 2.2.15 PHP 5.2.13


This is really weird. When I got to this URI in my application:

/view/course/teid/1/cid/-1/pos/30

Apache crashes.

When I go to a very similar URI - like this one:

/view/course/teid/1/cid/-1/pos/29

Everything works fine.

This is from error log:

[Thu Aug 05 11:22:14 2010] [notice] Parent: child process exited with status 255 -- Restarting.

I have been able to track down the line which causes the Apache to crash:

if (true === $aCourseTree->SetNodePassed($node)) { // this line crashes Apache
    self::writeTreeToDb($aCourseTree, $training, $this->aUtils);
}

The method is here:

public function SetNodePassed(CourseTreeNode $theNode)
{
    $aWasChange = !isset($theNode->Passed) || $theNode->Passed !== true;
    $theNode->Passed = true;

    if ($aWasChange && isset($theNode->Parent)) {
        if (true === $this->AreChildrenPassed($theNode->Parent)) {
            $this->SetNodePassed($theNode->Parent);
        }
    }
    return $aWasChange;
}

What the hell is going on? If there is some error, it should just be a PHP error. Why does Apache crash?

+1  A: 

How are you running PHP in your Apache?

mod_php can easily kill an Apache worker process[1], and the correct course of action for the Apache server as a whole is to try to return to as 'clean' a state as possible. It is nearly impossible for a process to clean up after corrupted memory, but restarting is very safe and easy.[2] It goes a long way towards returning the system to a known-good state.

You may wish to switch to a FastCGI implementation instead of mod_php; if you need more reasons, here's a very well-written set of reasons:

http://www.majordojo.com/2007/11/is-mod-php-falling-out-of-favor-with-hosting-providers.php

[1] The PHP team asked Linux distribution security teams to stop calling php-interpreter crash bugs "security problems" -- they fixed those sorts of bugs so often, that remotely-exploitable security bugs in php and its libraries were getting drowned out in the noise.

[2] Of course, to re-execute itself, it would need to call one of the exec() functions on memory that could possibly be corrupted, but hopefully the only corrupted memory in the master Apache process would be the scoreboard. So a re-exec should be safe enough.

sarnold