Bug #77061 [Opn->Fbk]: file_exists() race condition when used with symlinks
| From: | requinix@php.net | Date: | Thu, 25 Oct 2018 19:59:05 +0000 |
| Subject: | Bug #77061 [Opn->Fbk]: file_exists() race condition when used with symlinks | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217685@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77061&edit=1
ID: 77061
Updated by: requinix@php.net
Reported by: brandon dot jansen63 at gmail dot com
Summary: file_exists() race condition when used with symlinks
-Status: Open
+Status: Feedback
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Windows 7/10
PHP Version: 5.6.38
Block user comment: N
Private report: N
New Comment:
PHP 5.6 is not supported. Does this still happen with PHP 7.1 or later?
Previous Comments:
------------------------------------------------------------------------
[2018-10-25 19:14:24] brandon dot jansen63 at gmail dot com
Description:
------------
If the following conditions are met:
1) Two simultaneous calls to file_exists() are made for the same file for which file_exists() would
normally return TRUE,
2) The path given to file_exists() includes a directory which is a symlink (created with mklink /D),
3) PHP has not cached the real path of the file,
Then one of the calls to file_exists() may return FALSE while the other returns TRUE.
Test script:
---------------
<?php
echo "Starting...\r\n";
while( file_exists( 'C:\test_symlink\test.txt' ) )
{
clearstatcache( true );
}
echo "You shouldn't see this message.\r\n";
?>
Expected result:
----------------
Assuming that a file "test.txt" has been created somewhere on the file system, and that
the symlink C:\test_symlink has been created with the following command:
mklink /D C:\test_symlink <path-to-test.txt-containing-folder>
Then when two instances of the test script are run in parallel, each should display the message
"Starting..." and continue to run with no further output until manually terminated.
Actual result:
--------------
Each of the two instances of the test script displays "Starting...". However, after the
second instance is started, one of the instances terminates with the message "You
shouldn't see this message."
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77061&edit=1