Bug #77595 [NEW]: concurrent processes prevent filesize() from working

From: Date: Sun, 10 Feb 2019 05:43:00 +0000
Subject: Bug #77595 [NEW]: concurrent processes prevent filesize() from working
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219465@lists.php.net to get a copy of this message
From: Wes dot nospam at example dot org Operating system: Windows PHP version: 7.2.15 Package: *Directory/Filesystem functions Bug Type: Bug Bug description:concurrent processes prevent filesize() from working Description: ------------ other processes are denied to write the file while it is shared-locked, but attempting to do so prevents filesize() from working Test script: --------------- <?php // create a file of 6 bytes $path = __DIR__ . "/foo.txt"; file_put_contents($path, "123456"); // (1) // open that file for read and shared-lock it $file = fopen($path, "r"); flock($file, LOCK_SH | LOCK_NB); // (2) // attempt to write that file concurrently while the lock is active echo php -r "file_put_contents('$path', 'baz');"; // this step fails as expected -- means the file is still "123456" // (3) // attempt to read the file's size clearstatcache(FALSE, $path); $fileSize = filesize($path); // should return 6 bytes but returns 0 // (4) // this fails as consequence echo $fileSize . "\n"; echo fread($file, $fileSize); flock($file, LOCK_UN); fclose($file); Expected result: ---------------- should work as if the step (2) was commented out -- Edit bug report at https://bugs.php.net/bug.php?id=77595&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77595&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77595&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77595&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77595&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77595&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77595&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77595&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77595&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77595&r=support Expected behavior: https://bugs.php.net/fix.php?id=77595&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77595&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77595&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77595&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77595&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77595&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77595&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77595&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77595&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77595&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77595&r=mysqlcfg

« previous php.bugs (#219465) next »