#6788 [Com]: dbase read functions lead to random segfault

From: Date: Thu, 08 May 2003 14:10:14 +0000
Subject: #6788 [Com]: dbase read functions lead to random segfault
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39303@lists.php.net to get a copy of this message
ID: 6788 Comment by: tim at timcrider dot com Reported By: moron at industrial dot org Status: Closed Bug Type: dBase related Operating System: Redhat 6.2 PHP Version: 4.0.2 New Comment: This bug still exists in PHP 4.3.2-RC2. -----[ Code ]----- #!/bin/php -q <?php $db = dbase_open("../../Student_Data/teacher.dbf",2); print "I found ".dbase_numrecords($db)." # " . dbase_numfields($db) . " records\n"; dbase_pack($db); $stk = dbase_get_record_with_names($db,1); print "OK"; ?> -----[ Output ]----- (towely) Old# ./teacher.php I found 3178 # 13 records Segmentation fault -----[ PHP Configuration ]----- ./configure --prefix=/usr/local \ --with-apache=../www \ --with-gettext \ --with-gd \ --with-jpeg-dir=/usr/local \ --with-mcrypt=/usr/local \ --with-mcal=/usr/local \ --with-ming=/usr/local \ --with-mhash=/usr/local \ --with-mysql=/usr/local \ --with-pdflib=/usr/local \ --with-zlib=/usr/local \ --with-ncurses=/usr/local \ --with-tiff-dir="/usr/local" \ --with-unixODBC=/usr/local/unixODBC \ --with-xml \ --with-calendar=shared \ --with-png-dir=/usr/local \ --with-freetype=/usr/local \ --with-freetype-dir=/usr/local \ --with-ttf=/usr/local \ --with-fdftk=/usr/local \ --with-openssl=/usr/local \ --with-bz2 \ --with-dom \ --with-mm \ --with-pspell=/usr/local \ --enable-localizer \ --enable-bcmath \ --enable-calendar \ --enable-dio \ --enable-exif \ --enable-ftp \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-shmop \ --enable-sigchild \ --enable-sockets \ --enable-track-vars \ --enable-magic-quotes \ --enable-trans-sid \ --enable-libgcc \ --enable-wddx \ --enable-sysvshm \ --enable-sysvsem \ --enable-sysvmsg \ --enable-mbstring \ --enable-mbstr-enc-trans \ --enable-dbase \ --enable-mbregex If there is any other data you need, please let me know. Tim Previous Comments: ------------------------------------------------------------------------ [2001-10-09 04:40:56] sniper@php.net Please try the latest CVS snapshot from http://snaps.php.net/ as this should now be fixed. --Jani ------------------------------------------------------------------------ [2000-09-17 07:24:28] moron at industrial dot org 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"; } ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=6788&edit=1

« previous php.bugs (#39303) next »