#31048 [NEW]: PHP crashes if fpassthru() is used along with fseek()

From: Date: Fri, 10 Dec 2004 01:40:19 +0000
Subject: #31048 [NEW]: PHP crashes if fpassthru() is used along with fseek()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-70003@lists.php.net to get a copy of this message
From: john dot wellesz at teaser dot fr Operating system: FreeBSD 4.9 STABLE and WINXPSP2 PHP version: 5.0.2 PHP Bug Type: Reproducible crash Bug description: PHP crashes if fpassthru() is used along with fseek() Description: ------------ The bug I'm about to describe happens on Windows XP SP2 and freeBSD 4.9 STABLE and probably other platforms (I'm currently using PHP 5.0.2 on both). My 2 php (winXP and FreeBSD) run as CGI, the crashes also happens if I execute my script on command line. Modules used is probably irrelevant (and futile?), I use 2 PHP, one on FreeBSD and the other on winXP compiled on totally different way with not the same modules... (tell me if you can't reproduce the crash, i'll provide more info). ---------------- BUG REQUIREMENTS: --> You must have a file of at least 300Kb in size (200Kb won't make PHP to crash) --> You must have set the file pointer with fseek at 200,000 bytes (other values may not produce the bug) from the beginning of the file. --> You must call fpassthru() to print the rest of the file. Reproduce code: --------------- <?php //test file path $loginfo="fpassthru_crash_test_file"; //create the file; touch($loginfo); //allocate ~300000 bytes in the files (the file will make 300003 bytes) $handle=fopen($loginfo, "r+b"); ftruncate($handle,0); fseek($handle, 300000, SEEK_END); fwrite($handle,"END"); fclose($handle); //Open it for reading $handle=fopen($loginfo, "rb"); fseek($handle, 200000, SEEK_SET);//the 200000 is important, other values may not trigger the bug fpassthru($handle); ?> Expected result: ---------------- PHP should print the file till the end, we should see "END"... Actual result: -------------- PHP displays the file till the 98304th byte and crashes with a bus error (Signal 10). -- Edit bug report at http://bugs.php.net/?id=31048&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31048&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31048&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31048&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31048&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31048&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31048&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31048&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31048&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31048&r=support Expected behavior: http://bugs.php.net/fix.php?id=31048&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31048&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31048&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31048&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31048&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31048&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31048&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31048&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31048&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=31048&r=mysqlcfg

« previous php.bugs (#70003) next »