php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6788 dbase read functions lead to random segfault
Submitted: 2000-09-17 07:24 UTC Modified: 2001-10-09 04:40 UTC
From: moron at industrial dot org Assigned:
Status: Closed Package: dBase related
PHP Version: 4.0.2 OS: Redhat 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: moron at industrial dot org
New email:
PHP Version: OS:

 

 [2000-09-17 07:24 UTC] 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";
 }
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-09 04:40 UTC] sniper@php.net
Please try the latest CVS snapshot from http://snaps.php.net/ as this should now be fixed.

--Jani

 [2003-05-08 09:10 UTC] tim at timcrider dot com
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
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 09 00:03:37 2021 UTC