PHP 4.0 Bug #6788: dbase read functions lead to random segfault
| From: | moron at industrial dot org | Date: | Sun, 17 Sep 2000 11:24:28 +0000 |
| Subject: | PHP 4.0 Bug #6788: dbase read functions lead to random segfault | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-33393@lists.php.net to get a copy of this message | ||
From: moron@industrial.org
Operating system: Redhat 6.2
PHP version: 4.0.2
PHP Bug Type: dBase related
Bug description: dbase read functions lead to random segfault
I am experiencing some really annoying behaviour under PHP 4 that appears to be a bug in PHP but
maybe is some issue to do with upgrading? Anyways, using the DBF read functions results in random
seg faults (Apache's error_log states "child pid 12345 exit signal Segmentation
Fault"). This seems to have no rhyme or reason - it will crash on one run and work on fine on
the next. I thought it was a timeout issue initially but that seems to not be the case. I am
working with an 8000 line DBF file which I have another script that is trying to import it into a
MySQL database. The example code below is just to show the bug and just reads the file out. It
fails about 40% of the time for me. My "real" script dies consistently though, probably
due to the amount of other stuff going on. If you need an example dbf file please let me know.
<?PHP
if($fp = dbase_open("./import/prices1.DBF",0)) {
$num_records=dbase_numrecords($fp);
$x=1;
echo "<TABLE WIDTH=100%>\n";
while(($x<=800)&&($x<=$num_records)) {
echo "<TR>";
if(! ($row = dbase_get_record_with_names($fp, $x))) { $x++; next; }
reset($row);
while(key($row)) { echo "<TD>Field: ".key($row)."=".$row[ key($row)
]."</TD>\n"; next($row); }
unset($row);
flush();
$x++;
echo "</TR>\n";
}
flush();
printf("<TR><TD WIDTH=20%% ALIGN=RIGHT BgColor=#8080c0></TD><TD
WIDTH=20%% ALIGN=CENTER></TD><TD WIDTH=60%%><FONT face=\"arial,
helvitica\">%d records read</FONT></TD></TR>\n",$x-1);
echo "</TABLE>\n";
}
?>