|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74900 Random file not found on multiple processes
Submitted: 2017-07-11 12:32 UTC Modified: 2017-08-06 04:22 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: falk dot aaron85 at gmail dot com Assigned:
Status: No Feedback Package: *Directory/Filesystem functions
PHP Version: Irrelevant OS: Windows Server 2012 R2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-07-11 12:32 UTC] falk dot aaron85 at gmail dot com
I'm using php 7.0.9NTSx64 on a IIS 8.5 (Windows 2012 R2) to provide a TYPO3 website. Unfortunately, randomly occurs a "No such file or directory" error on calling file_get_contents() for a local static file (e.g. svg images).

Before the file_get_contents() call a file_exists() call is executed to verify that the file exists and it does indeed:

I can reproduce the error by clearing the backend caches of TYPO3 and then opening 40 tabs of the List menu.

In the frontend the error occurs randomly, maybe when multiple clients are using the website, but i cannot reproduce it.

Another strange thing is, that when i clear the application pool on IIS, the error will not occur for a few hours.

I already tried to use different PHP versions (5.x-7.x with and without fastCGI), disabling symbolic links, ... but nothing resolved the problem.

The error only occurs under Windows machines, not under Linux or MacOS. You're also able to reproduce it in shell.

Test script:
1..5 | ForEach-Object { Start-Job { c:\phptest\php-ts\php.exe -f c:\phptest\test.php } } | Out-Null
Get-Job | Receive-Job
Get-Job | Remove-Job -Force

ini_set('display_errors', 1);
error_reporting( E_ALL );
$path = '/path/to/';
for ($i = 0; $i < 100; $i++) {
        echo "File Exists" . PHP_EOL;
        echo "FileSize".PHP_EOL;
        echo "RealPath".PHP_EOL;
        echo "FileGetContents".PHP_EOL;
        echo "Fopen".PHP_EOL;
    var_dump(fopen($path, 'rb'));
        echo PHP_EOL . PHP_EOL;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-12 15:57 UTC]
-Status: Open +Status: Feedback
 [2017-07-12 15:57 UTC]
Thanks for the report. I don't reproduce this locally using your PS script. Also, from the PHP supplied - if a path like /path/to/file.zi is used, that might be the issue. If such a path indeed is used, please switch to an absolute path and try again.

 [2017-07-12 16:01 UTC] falk dot aaron85 at gmail dot com
-Status: Feedback +Status: Open
 [2017-07-12 16:01 UTC] falk dot aaron85 at gmail dot com
No, i use a absolute path like C:/
The path in the an absolute path for unix systems.

I am able fto reproduce the problem on windows systems with different php versions. You could maybe try to increase the size of the for loop and the amount of php processes started in parallel.
 [2017-07-12 16:21 UTC]
-Status: Open +Status: Feedback
 [2017-07-12 16:21 UTC]
Still no luck. I've changed your code to a bit shorter version

ini_set('display_errors', 1);
error_reporting( E_ALL );
$path = 'C:\path\to\file';
for ($i = 0; $i < 100; $i++) {
        if (!file_exists($path)) {
                die("Doesn't exist");
        if (!file_get_contents($path)) {
                die("No content");

echo "all clean";

and used up to 32 processes, but all i get is "all clean" outputs. You told you've used other PHP versions, have you tried latest versions or just some? Also, does this reproduce on another machine?

 [2017-07-12 16:41 UTC] falk dot aaron85 at gmail dot com
-Status: Feedback +Status: Open
 [2017-07-12 16:41 UTC] falk dot aaron85 at gmail dot com
I tried it on 3 different windows machines with php 5.5, 5.6, 7.0 and 7.1. It can reproduce it on all systems with all php versions.

Randomly the file_get_contents gets the error failes to open stream: no such file or directory...
 [2017-07-12 16:52 UTC]
Ok, lets see. Perhaps someone else has better luck reproducing this of finding a better reproducer.

 [2017-07-12 16:57 UTC] falk dot aaron85 at gmail dot com
Tried it with 7.0.14RC1 on Windows 10 and cannot reproduce it.
 [2017-07-14 13:50 UTC] falk dot aaron85 at gmail dot com
I found out that this problem does only occurs if in the path of the file to read is a symbolic link (/D or /J) inside.

Without symbolic links, I am not able to reproduce the issue.
Could you please try it with the use of symbolic link(s) in the path of the file to read?
 [2017-07-24 16:41 UTC]
-Status: Open +Status: Feedback
 [2017-07-24 16:41 UTC]
Some questions yet

- do you run php as an elevated user?
- do you create symlinks with php, or if not - what is the exact mklink or junction command line?
- what are the ACLs on the symlink and on the file (use icacls)?

 [2017-08-06 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 15:03:37 2021 UTC