php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39063 is_file() and file_exists() returning false on high load
Submitted: 2006-10-06 14:18 UTC Modified: 2006-10-23 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: nherdananto at gmail dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 4.4.4 OS: FreeBSD 5.5
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: nherdananto at gmail dot com
New email:
PHP Version: OS:

 

 [2006-10-06 14:18 UTC] nherdananto at gmail dot com
Description:
------------
is_file() or file_exists() returning false on existing file.
the script is executed about 8x per second and checking a file in a directory filled with 5000 to 30000 files.
for 344000 execution, it fails about 2000 times.
no change on php.ini

Reproduce code:
---------------
$tid = isset( $_GET['tid'] ) ? $_GET['tid'] : "";

$file = "/data/".$tid.".txt";
if(file_exists()) {
      echo "1";
} else {
      echo "0";
}

Expected result:
----------------
for 344000 execution, it should producing 1 for 344000 times.

Actual result:
--------------
less than 344000 times of 1 echoed.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-06 14:20 UTC] nherdananto at gmail dot com
sorry, wrong code. here's the code

$tid = isset( $_GET['tid'] ) ? $_GET['tid'] : "";

$file = "/data/".$tid.".txt";
if(file_exists($file)) {
      echo "1";
} else {
      echo "0";
}
 [2006-10-06 14:40 UTC] tony2001@php.net
What kind of server API are you using and is it threaded or not?
 [2006-10-06 14:58 UTC] nherdananto at gmail dot com
im running apache 2.0.59
and yes, threaded, limited to 256 thread.
 [2006-10-15 21:45 UTC] bjori@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

(Yes. We know you reported this against 4.4, but we want 
to know if you can reproduce this under 5.2)

Running 5.2.0RC6-dev on Apache/2.0.59 worker as 
apache2handler.

bjori@lindsay test$ uname -rs
FreeBSD 6.1-STABLE
bjori@lindsay test$ cat test.php
<?php
$tid = isset( $_GET['tid'] ) ? $_GET['tid'] : "";

if(!file_exists($tid)) {
      echo "WRONG";
}
bjori@lindsay test$ COUNT=1; until [ $COUNT -gt 30000 ]; 
do touch $COUNT.txt; let COUNT+=1; done
bjori@lindsay test$ COUNT=1; until [ $COUNT -gt 344000 ]; 
do file=`/bin/ls | random -f - | head -n1`; fetch -q -o - 
http://localhost/test/test.php?tid=$file; let COUNT+=1; 
done

After ca 6hours and over 100000 requests (~5req/sec) I 
haven't been able to reproduce this...
 [2006-10-23 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 01:01:28 2024 UTC