Blank page - child exit on bus error
Posted: Tue Aug 26, 2003 8:00 am
Hi everybody,
I'm quite new to PHP and am experiencing a very difficult problem.
After our sysadmins upgraded the Apache webserver (from 1.x to 2.x) and PHP to PHP4,
one of my php scripts no longer works.
What is even more annoying, is that I don't even get an error message (as usual), but just a blank page. When I looked at the Apache log, it mentions "child exit - bus error" (at first also child exit on segmentation fault, but now it's a bus error). I've tried to implement the error handler and output handler written by WebKreator, but with no luck.
As I'm completely stuck right now and because my site is an important one, I'd appreciate any help or input. I'd like to fix the errors or at least some clues as to identify what is going on.
So, PLEASE help me!
It also seems that the substr() function does not always work as it should. In some cases it works and in others it doesn't. But I'm not sure that this causes the blank page and child error.
The code of the script is as follows:
$month=array("Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec");
$id=getMyPid();
/*Read all filenames of maps*/
$Maps=file("tmp/Map_$REMOTE_HOST");
/*Count the number of maps*/
$nMaps=count($Maps);
/*define JavaScript arrays*/
print("myImages=new Array;\n");
print("titleArray=new Array;\n");
print("legendArray=new Array;\n");
/*include the legend array, which defines the color bar you need to use for each map*/
require 'scales.php'; /*this pastes the scales.php file into the HTML code of the site. Instead, we want the lines of scales.php to be executed here*/
/*You will need to enclose the code in scales .php inside the php tags (<? and ?>), so that the php code, pasted in the html code, is again treated as php code*/
/*test 4th character in map's URL (M in MapsM/..., D in MapsD1 or MapsD3)*/
/*NOT NECESSARY FOR SO2 - only 1 projection!*/
/*loop over all maps*/
for ($i=0,$j=0;$i<$nMaps;$i++)
{
$n=strlen($Maps[$i]);
/*split the i'th Maps element (string) in separate parts*/
list($mapType,$dirname,$year,$file)=explode("/",$Maps[$i]);
/*IF-TEST IS NOT NECESSARY FOR SO2: only 1 projection!*/
/*current map's projection must be same as the selected map's projection*/
/*if ($Maps[$i][$projIdx]==$proj)*/
/*{*/
/*print "framenr=" line for current map (=map that was clicked on), framenr starts the ZoomAnimation at the right frame (=element in array)*/
if ($i==$curMap)
print("framenr=".$j.";\n");
print("myImages[".$j."]='".substr($Maps[$i],0,$n-1)."';\n");
/*JE KUNT OOK $mapType gebruiken in de if-test!*/
if (substr($Maps[$i],4,1)=='M')
{
$mm=substr($Maps[$i],-7,2);
$yyyy=substr($Maps[$i],-12,4);
$datestr=$yyyy."_".$mm;
print("titleArray[".$j."]='GOME SO2, ".$month[intval($mm)-1]." ".$yyyy."';\n");
$nItem=count($legend[$mapType][$dirname]["sdate"]);
$cbfound=0;
/*DEBUG*/
/*print("ITEMS: ".$nItem."\n");*/
/*Following test proves that the file has been included/legend array exists*/
/*print("TEST: ".$legend["MapsM"]["Mexico"]["edate"][0]."\n");
print("TEST: ".$legend[$mapType][$dirname]["edate"][0]."\n");
*/
for($k=0;$k<$nItem;$k++)
{
if($legend[$mapType][$dirname]["sdate"][$k]<=$datestr && $legend[$mapType][$dirname]["edate"][$k]>=$datestr)
{
print("legendArray[".$j."]='".$legend[$mapType][$dirname]["legend"][$k]."';\n");
$cbfound=1;
}
}
if($cbfound==0)
{
/*you can give an error, specify a default file or an empty string*/
/*BEST: give a default image, otherwise ZoomAnimation might fail!*/
/*NO: might be confusing for the user, unless the color bar is clearly marked (eg with a text on it) as "unreliable" or something*/
print("legendArray[".$j."]='dynapi/ColorBars/CB_Not_Found.gif';\n");
}
}
else
{ if (substr($Maps[$i],5,1)=='1')
{
$mm=substr($Maps[$i],-10,2);
$yyyy=substr($Maps[$i],-15,4);
$datestr=$yyyy."_".$mm;
print("titleArray[".$j."]='GOME SO2, ".intval(substr($Maps[$i],-7,2))." ".$month[intval($mm)-1]." ".$yyyy."';\n");
$nItem=count($legend[$mapType][$dirname]["sdate"]);
$cbfound=0;
/*DEBUG*/
/*print("ITEMS: ".$nItem."\n");*/
for($k=0;$k<$nItem;$k++)
{
if($legend[$mapType][$dirname]["sdate"][$k]<=$datestr && $legend[$mapType][$dirname]["edate"][$k]>=$datestr)
{
print("legendArray[".$j."]='".$legend[$mapType][$dirname]["legend"][$k]."';\n");
$cbfound=1;
}
}
if($cbfound==0)
{
/*you can give an error, specify a default file or an empty string*/
/*BEST: give a default image, otherwise ZoomAnimation might fail!*/
/*NO: might be confusing for the user, unless the color bar is clearly marked (eg with a text on it) as "unreliable" or something*/
print("legendArray[".$j."]='dynapi/ColorBars/CB_Not_Found.gif';\n");
}
}
else
{
/*3-day map: "middle" day's dd is inside map's filename*/
$day1=intval(substr($Maps[$i],-7,2))-1;
$day2=intval(substr($Maps[$i],-7,2))+1;
$mm=substr($Maps[$i],-10,2);
/*DEBUG: this was used to test the indexes of substr() for $mm*/
/*print("MM: $mm MAP $Maps[$i]\n");*/
$yyyy=substr($Maps[$i],-15,4);
$datestr=$yyyy."_".$mm;
print("titleArray[".$j."]='GOME SO2, ".$day1."-".$day2." ".$month[intval($mm)-1]." ".$yyyy."';\n");
$nItem=count($legend[$mapType][$dirname]["sdate"]);
$cbfound=0;
/*DEBUG*/
/*print("ITEMS: ".$nItem."\n");*/
for($k=0;$k<$nItem;$k++)
{
if($legend[$mapType][$dirname]["sdate"][$k]<=$datestr && $legend[$mapType][$dirname]["edate"][$k]>=$datestr)
{
print("legendArray[".$j."]='".$legend[$mapType][$dirname]["legend"][$k]."';\n");
$cbfound=1;
}
}
if($cbfound==0)
{
/*you can give an error, specify a default file or an empty string*/
/*BEST: give a default image, otherwise ZoomAnimation might fail!*/
/*NO: might be confusing for the user, unless the color bar is clearly marked (eg with a text on it) as "unreliable" or something*/
print("legendArray[".$j."]='dynapi/ColorBars/CB_Not_Found.gif';\n");
}
}
}
$j++;
/*}*/
}
/*is replaced by parameter in config file (to make the legend depend on the region/volcano, because there is 1 config file for each region/volcano)*/
/*print("legend='BrO_Legend.gif';\n");*/
/*BETER: resize laten afhangen van imgSize of zo (vb resizeTo(imgWidth+200,imgHeight+150) - geef ruimte aan de buttonlayers!)*/
/*print("window.resizeTo(725,mapHeight+300); \n");*/
print("window.resizeTo(mapWidth+legendWidth+160,mapHeight+300); \n");
print("window.moveTo(10,10); \n");
I'm quite new to PHP and am experiencing a very difficult problem.
After our sysadmins upgraded the Apache webserver (from 1.x to 2.x) and PHP to PHP4,
one of my php scripts no longer works.
What is even more annoying, is that I don't even get an error message (as usual), but just a blank page. When I looked at the Apache log, it mentions "child exit - bus error" (at first also child exit on segmentation fault, but now it's a bus error). I've tried to implement the error handler and output handler written by WebKreator, but with no luck.
As I'm completely stuck right now and because my site is an important one, I'd appreciate any help or input. I'd like to fix the errors or at least some clues as to identify what is going on.
So, PLEASE help me!
It also seems that the substr() function does not always work as it should. In some cases it works and in others it doesn't. But I'm not sure that this causes the blank page and child error.
The code of the script is as follows:
$month=array("Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec");
$id=getMyPid();
/*Read all filenames of maps*/
$Maps=file("tmp/Map_$REMOTE_HOST");
/*Count the number of maps*/
$nMaps=count($Maps);
/*define JavaScript arrays*/
print("myImages=new Array;\n");
print("titleArray=new Array;\n");
print("legendArray=new Array;\n");
/*include the legend array, which defines the color bar you need to use for each map*/
require 'scales.php'; /*this pastes the scales.php file into the HTML code of the site. Instead, we want the lines of scales.php to be executed here*/
/*You will need to enclose the code in scales .php inside the php tags (<? and ?>), so that the php code, pasted in the html code, is again treated as php code*/
/*test 4th character in map's URL (M in MapsM/..., D in MapsD1 or MapsD3)*/
/*NOT NECESSARY FOR SO2 - only 1 projection!*/
/*loop over all maps*/
for ($i=0,$j=0;$i<$nMaps;$i++)
{
$n=strlen($Maps[$i]);
/*split the i'th Maps element (string) in separate parts*/
list($mapType,$dirname,$year,$file)=explode("/",$Maps[$i]);
/*IF-TEST IS NOT NECESSARY FOR SO2: only 1 projection!*/
/*current map's projection must be same as the selected map's projection*/
/*if ($Maps[$i][$projIdx]==$proj)*/
/*{*/
/*print "framenr=" line for current map (=map that was clicked on), framenr starts the ZoomAnimation at the right frame (=element in array)*/
if ($i==$curMap)
print("framenr=".$j.";\n");
print("myImages[".$j."]='".substr($Maps[$i],0,$n-1)."';\n");
/*JE KUNT OOK $mapType gebruiken in de if-test!*/
if (substr($Maps[$i],4,1)=='M')
{
$mm=substr($Maps[$i],-7,2);
$yyyy=substr($Maps[$i],-12,4);
$datestr=$yyyy."_".$mm;
print("titleArray[".$j."]='GOME SO2, ".$month[intval($mm)-1]." ".$yyyy."';\n");
$nItem=count($legend[$mapType][$dirname]["sdate"]);
$cbfound=0;
/*DEBUG*/
/*print("ITEMS: ".$nItem."\n");*/
/*Following test proves that the file has been included/legend array exists*/
/*print("TEST: ".$legend["MapsM"]["Mexico"]["edate"][0]."\n");
print("TEST: ".$legend[$mapType][$dirname]["edate"][0]."\n");
*/
for($k=0;$k<$nItem;$k++)
{
if($legend[$mapType][$dirname]["sdate"][$k]<=$datestr && $legend[$mapType][$dirname]["edate"][$k]>=$datestr)
{
print("legendArray[".$j."]='".$legend[$mapType][$dirname]["legend"][$k]."';\n");
$cbfound=1;
}
}
if($cbfound==0)
{
/*you can give an error, specify a default file or an empty string*/
/*BEST: give a default image, otherwise ZoomAnimation might fail!*/
/*NO: might be confusing for the user, unless the color bar is clearly marked (eg with a text on it) as "unreliable" or something*/
print("legendArray[".$j."]='dynapi/ColorBars/CB_Not_Found.gif';\n");
}
}
else
{ if (substr($Maps[$i],5,1)=='1')
{
$mm=substr($Maps[$i],-10,2);
$yyyy=substr($Maps[$i],-15,4);
$datestr=$yyyy."_".$mm;
print("titleArray[".$j."]='GOME SO2, ".intval(substr($Maps[$i],-7,2))." ".$month[intval($mm)-1]." ".$yyyy."';\n");
$nItem=count($legend[$mapType][$dirname]["sdate"]);
$cbfound=0;
/*DEBUG*/
/*print("ITEMS: ".$nItem."\n");*/
for($k=0;$k<$nItem;$k++)
{
if($legend[$mapType][$dirname]["sdate"][$k]<=$datestr && $legend[$mapType][$dirname]["edate"][$k]>=$datestr)
{
print("legendArray[".$j."]='".$legend[$mapType][$dirname]["legend"][$k]."';\n");
$cbfound=1;
}
}
if($cbfound==0)
{
/*you can give an error, specify a default file or an empty string*/
/*BEST: give a default image, otherwise ZoomAnimation might fail!*/
/*NO: might be confusing for the user, unless the color bar is clearly marked (eg with a text on it) as "unreliable" or something*/
print("legendArray[".$j."]='dynapi/ColorBars/CB_Not_Found.gif';\n");
}
}
else
{
/*3-day map: "middle" day's dd is inside map's filename*/
$day1=intval(substr($Maps[$i],-7,2))-1;
$day2=intval(substr($Maps[$i],-7,2))+1;
$mm=substr($Maps[$i],-10,2);
/*DEBUG: this was used to test the indexes of substr() for $mm*/
/*print("MM: $mm MAP $Maps[$i]\n");*/
$yyyy=substr($Maps[$i],-15,4);
$datestr=$yyyy."_".$mm;
print("titleArray[".$j."]='GOME SO2, ".$day1."-".$day2." ".$month[intval($mm)-1]." ".$yyyy."';\n");
$nItem=count($legend[$mapType][$dirname]["sdate"]);
$cbfound=0;
/*DEBUG*/
/*print("ITEMS: ".$nItem."\n");*/
for($k=0;$k<$nItem;$k++)
{
if($legend[$mapType][$dirname]["sdate"][$k]<=$datestr && $legend[$mapType][$dirname]["edate"][$k]>=$datestr)
{
print("legendArray[".$j."]='".$legend[$mapType][$dirname]["legend"][$k]."';\n");
$cbfound=1;
}
}
if($cbfound==0)
{
/*you can give an error, specify a default file or an empty string*/
/*BEST: give a default image, otherwise ZoomAnimation might fail!*/
/*NO: might be confusing for the user, unless the color bar is clearly marked (eg with a text on it) as "unreliable" or something*/
print("legendArray[".$j."]='dynapi/ColorBars/CB_Not_Found.gif';\n");
}
}
}
$j++;
/*}*/
}
/*is replaced by parameter in config file (to make the legend depend on the region/volcano, because there is 1 config file for each region/volcano)*/
/*print("legend='BrO_Legend.gif';\n");*/
/*BETER: resize laten afhangen van imgSize of zo (vb resizeTo(imgWidth+200,imgHeight+150) - geef ruimte aan de buttonlayers!)*/
/*print("window.resizeTo(725,mapHeight+300); \n");*/
print("window.resizeTo(mapWidth+legendWidth+160,mapHeight+300); \n");
print("window.moveTo(10,10); \n");