php.net |  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
Votes:2
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: falk dot aaron85 at gmail dot com
New email:
PHP Version: OS:

 

 [2017-07-11 12:32 UTC] falk dot aaron85 at gmail dot com
Description:
------------
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


<?php
ini_set('display_errors', 1);
error_reporting( E_ALL );
$path = '/path/to/file.zip';
for ($i = 0; $i < 100; $i++) {
        echo "File Exists" . PHP_EOL;
        var_dump(file_exists($path));
        echo "FileSize".PHP_EOL;
    var_dump(filesize($path));
        echo "RealPath".PHP_EOL;
    var_dump(realpath($path));
        echo "FileGetContents".PHP_EOL;
    var_dump(strlen(file_get_contents($path)));
        echo "Fopen".PHP_EOL;
    var_dump(fopen($path, 'rb'));
        echo PHP_EOL . PHP_EOL;
}



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-12 15:57 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2017-07-12 15:57 UTC] ab@php.net
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.

Thanks.
 [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:/file.zip.
The path in the script.is 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] ab@php.net
-Status: Open +Status: Feedback
 [2017-07-12 16:21 UTC] ab@php.net
Still no luck. I've changed your code to a bit shorter version

<?php
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?

Thanks.
 [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] ab@php.net
Ok, lets see. Perhaps someone else has better luck reproducing this of finding a better reproducer.

Thanks.
 [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] ab@php.net
-Status: Open +Status: Feedback
 [2017-07-24 16:41 UTC] ab@php.net
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)?


Thanks.
 [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