OpenX causing Segmentation Fault (11) in PHP 5.3.6
There are lots of posts about OpenX causing Segmentation Faults in PHP 5.1 but I couldn’t find any posts for OpenX causing Segmentation Faults in PHP 5.3.6.
After a certain amount of hunting through the code, it would appear this is a quick fix.
Specifically, when I tried to edit a campaign I would get the following from Safari:
"Safari can’t open the page “http://www.domainname.com/ads/www/admin/campaign-edit.php?clientid=18&campaignid=20” because the server unexpectedly dropped the connection. This sometimes occurs when the server is busy. Wait for a few minutes, and then try again."
Firefox would try to download the URL, which gave me an empty campaign-edit.php file.
The server logs would show:
[Mon Jun 20 17:56:10 2011] [notice] child pid 26920 exit signal Segmentation fault (11)
After hunting for awhile, I came to the conclusion that “lib/max/SqlBuilder.php” was at fault, and more specifically the function _addLimitation. My theory on why this breaks PHP is this:
The developer calls _addLimitation with a reference to $aLimitations, and there fore doesn’t expect a return value. However, PHP now seems to want a return value, and I remember in my training at some point, not returning anything can, under certain conditions cause PHP to explode into a big gooey mess.
The fix is very easy: Using your favourite text editor, open lib/max/SqlBuilder.php, and go to roughly line 906. Then add ‘return true;’. To be more specific you will alter the function like this:
function _addLimitation(&$aLimitations, $entityIdName, $columnName, $value, $comparison_type = MAX_LIMITATION_EQUAL)
{
// Add single quotes around non-integer columns
if (($entityIdName == 'ad_type')
|| ($entityIdName == 'ad_active')
|| ($entityIdName == 'placement_active')
|| ($entityIdName == 'placement_anonymous')
) {
$value = "'" . str_replace(',', "','", $value) . "'";
}
// If there are multiple values, use IN instead of =
if (strpos($value, ',') !== false) {
$aLimitations[] = "$columnName IN ($value)";
} else {
switch ($comparison_type) {
case MAX_LIMITATION_NOT_EQUAL:
$aLimitations[] = "$columnName != $value";
break;
case MAX_LIMITATION_BITWISE:
$aLimitations[] = "($columnName & $value > 0)";
break;
default:
$aLimitations[] = "$columnName = $value";
break;
}
}
// Add the following line to stop Segmentation Faults
return true;
}
If this helps you out, please let me know. I have not posted this as a bug at OpenX as I find the OpenX site too confusing to bother.