Edit report at https://bugs.php.net/bug.php?id=79486&edit=1
ID: 79486
Updated by: cmb@php.net
Reported by: m dot staab at complex-it dot de
Summary: file_exists() returns true for a non-existing file
-Status: Assigned
+Status: Open
Type: Bug
Package: *General Issues
-Operating System: windows10 x64
+Operating System: *
-PHP Version: 7.4.5
+PHP Version: 7.3
-Assigned To: cmb
+Assigned To:
Block user comment: N
Private report: N
New Comment:
> I did some more tests and can reproduce the issue also on php> 7.2.30 and also on ubuntu18
Then strace might be helpful.
Previous Comments:
------------------------------------------------------------------------
[2020-04-20 08:57:13] m dot staab at complex-it dot de
I did some more tests and can reproduce the issue also on php 7.2.30 and also on ubuntu18
not sure where the problem cause could be
------------------------------------------------------------------------
[2020-04-18 12:49:10] m dot staab at complex-it dot de
I dont have a buildenv on my workstation (and actually dont want to setup one).
Anything else I could do to to ahead?
I thought about downloading a 7.2 and/or 7.3 binary to test whether the issue was present before.
I could offer a teamviewer pairing session, so you can have a look at it right on the machine..
------------------------------------------------------------------------
[2020-04-18 10:41:31] cmb@php.net
Thanks for the further info!
Since this issue is obviously not easily reproducible, and I have
doubts that tracing with Process Monitor[1] will reveal the
underlying issue, I can only speculate. As of PHP 7.4.0, the
stat() call (either explicitly or implictly) ends up in
php_win32_ioutil_fstat_int()[2], and given that that the uid and
gid members are not zero, it looks like your hitting the
_fstat64() fallback[3]. This code path uses _open_osfhandle(),
but apparently doesn't regard that "The _open_osfhandle call
transfers ownership of the Win32 file handle to the file
descriptor."[4] If the documentation is correct, this might
indeed cause issues.
Would you have a PHP build environment[5] available, to do some
debugging, or trying out some potential fixes? Otherwise I could
try to apply fixes, and provide pre-built binaries for testing,
but that would be somewhat tedious.
[1] <https://docs.microsoft.com/en-us/sysinternals/downloads/procmon>
[2] <https://github.com/php/php-src/blob/php-7.4.5/win32/ioutil.c#L860>
[3] <https://github.com/php/php-src/blob/php-7.4.5/win32/ioutil.c#L872-L888>
[4] <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-osfhandle?view=vs-2019>
[5] <https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2>
------------------------------------------------------------------------
[2020-04-18 06:47:54] m dot staab at complex-it dot de
Btw: I tried adding clearstatcache(true); right before the file_exists(), but this did not change
the result
------------------------------------------------------------------------
[2020-04-18 06:14:24] m dot staab at complex-it dot de
Not that I am aware of.
C:\Users\mstaab\Documents\GitHub\kunzmann is a regular git checkout of a private github repo
I am wondering why its not reproducible with a 3 line script from within the same path
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=79486
--
Edit this bug report at https://bugs.php.net/bug.php?id=79486&edit=1