Bug #18218 Updated: fclose crashes PHP and Apache

From: Date: Mon, 08 Jul 2002 12:21:21 +0000
Subject: Bug #18218 Updated: fclose crashes PHP and Apache
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-13513@lists.php.net to get a copy of this message
ID: 18218 Updated by: ray@unreal64.net Reported By: ray@unreal64.net Status: Open Bug Type: Filesystem function related Operating System: Windows NT4.0 PHP Version: 4.2.1 New Comment: Sorry for choosing bad cathegory initially. R. Previous Comments: ------------------------------------------------------------------------ [2002-07-08 05:47:30] sander@php.net Reclassified. ------------------------------------------------------------------------ [2002-07-08 03:59:22] ray@unreal64.net Hi ! We are using OpenBSD as server-side OS, and Windoze for testing. I found a problem, which can be a bug. If not, or someone allready reported (I didn't find), I am sorry. This bug accurs only at Windoze - all works perfect under OpenBSD. I have code (pseudo): fopen(file1,"r") if (fopen(file2,"r")) { stat(file1); stat(file2); // check timestamp if (stat1 VS stat2) { read(file2) into array (restore cache); close(file1); close(file2); return; } close(file2); } // rebuild cache read(file1); close(file1); process file1 data // store cache if (fopen(file3,"w+b")) { fwrite(file3,serialize(...)); fclose(file3); /****** HERE Apache/php CRASHES } File1 is 'source'. File2 is 'cache' - read only. I check last modify time, if valid, then I read cache. If not, I process source, re-open cache for writing and store datas. At fclose process die. If I remove fclose, all works fine (other file operations, DB access, etc.). If I remove initiali fopen for cache and time checking (fstat), then fclose3 also works perfect. My own opinion: openning files/stating them/closing causes PHP die. Have a nice day, Don't kill me :o) Bye Ray There is original code (class function): // read strings file function cmdLngFile($fname) { $fnamec="../cache/".basename($fname); if (!file_exists($fname)) stlc_exit("lng file $fname not found"); $fd=@fopen($fname,"r"); if (empty($fd)) stlc_exit("can't read or empty lng $fname"); $fdc=@fopen($fnamec,"rb"); if (!empty($fdc)) { $statn=fstat($fd); $statc=fstat($fdc); // use cache if ($statn[9]<=$statc[9]) { $cache=fread($fdc,filesize($fnamec)); $this->lngs=array_merge($this->lngs,unserialize($cache)); fclose($fd); fclose($fdc); return; } // need rebuild cache... fclose($fdc); } $lng=fread($fd,filesize($fname)); fclose($fd); // process file contents $lnglen=strlen($lng); ... nothing interested here, jsut process language file and setup array $this->lngs in form array["language_id"] => "text" // store cache $fdcw=@fopen($fnamec,"w+b"); if (!empty($fdcw)) { $cache=serialize($this->lngs); fwrite($fdcw,$cache); fflush($fdcw); //!!!! PHP bug (?) - this falldown apache on windoze, BSD works // keep comment for windoze //fclose($fdcw); } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18218&edit=1

« previous php.bugs (#13513) next »