Bug #72517 [Opn->Fbk]: file_exists(), is_file() and stat() report wrong result infrequently (~1%)

From: Date: Thu, 30 Jun 2016 07:50:10 +0000
Subject: Bug #72517 [Opn->Fbk]: file_exists(), is_file() and stat() report wrong result infrequently (~1%)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201927@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72517&edit=1 ID: 72517 Updated by: requinix@php.net Reported by: stgrein at gmail dot com -Summary: file_exists(), is_file() and stat() report wrong result +Summary: file_exists(), is_file() and stat() report wrong result infrequently (~1%) -Status: Open +Status: Feedback Type: Bug Package: Filesystem function related Operating System: Windows PHP Version: 7.0.8 Block user comment: N Private report: N New Comment: Here's a cmd command to repeat the test 10k times: (for /l %i in (1,1,10000) do php -r "var_dump(file_exists('/this/file/exists'));") | find /c "true" Naturally it needs to be run from where you have PHP installed (or give the path to php.exe) and you need to change the /this/file/exists path. If you run that, does it show 10000 or something less? What if the system and/or disk is under load? Also, if you're getting this behavior with regular PHP code, are you potentially creating that file first? Because PHP will cache stat information during execution; if you are creating the file then use clearstatcache() before re-testing for the presence of the file. http://php.net/manual/en/function.clearstatcache.php Also, testing with PHP 5.5 or 5.6 would be appreciated. Previous Comments: ------------------------------------------------------------------------ [2016-06-29 20:10:28] stgrein at gmail dot com Additional information: I used the VC14 x64 Thread Safe build from windows.php.net ------------------------------------------------------------------------ [2016-06-29 20:08:20] stgrein at gmail dot com Description: ------------ Hi, functions which check if a file exists do report wrong results sometimes. I did not find a special pattern, but maybe higher load is triggering it more. The chance on my machine is around ~1% to hit the bug per function call. I am using PHP v7.0.8 now but also had this bug on PHP v7.0.7. I did not test with earlier Versions. Test script: --------------- <?php //check an existing file $a = file_exists("/this/file/exists"); if($a === true) { echo "File exists!"; //expected } else { echo "File does NOT exists!"; //bug hit } //expected output: //File exists! //chance to get this output is around 1% on my machine under load //File does NOT exists! ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72517&edit=1

« previous php.bugs (#201927) next »