Bug #52312 [Bgs]: PHP lstat problem
| From: | rasmus@php.net | Date: | Mon, 12 Jul 2010 15:07:40 +0000 |
| Subject: | Bug #52312 [Bgs]: PHP lstat problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152312@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52312&edit=1
ID: 52312
Updated by: rasmus@php.net
Reported by: v dot damore at gmail dot com
Summary: PHP lstat problem
Status: Bogus
Type: Bug
Package: Safe Mode/open_basedir
Operating System: Linux
PHP Version: 5.2.13
New Comment:
phpinfo() is a special case. Try it with a simple hello world script.
Previous Comments:
------------------------------------------------------------------------
[2010-07-12 16:56:36] v dot damore at gmail dot com
The real problem is that such full scan are repeated more then once:
25933 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
25933 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php",
{st_mode=S_IFREG|0644, st_size=16, ...}) = 0
First check
25933 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
25933 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php",
{st_mode=S_IFREG|0644, st_size=16, ...}) = 0
Second check
25933 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
25933 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
Third check (incomplete)
25933 lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
25933 lstat("/usr/local/myspace", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php",
{st_mode=S_IFREG|0644, st_size=16, ...}) = 0
Final check and then read the file.
25933 open("/usr/local/myspace/webspace/httpdocs/phpinfo.php", O_RDONLY)
= 16
25933 fstat(16, {st_mode=S_IFREG|0644, st_size=16, ...}) = 0
25933 read(16, "<? phpinfo() ?>\n", 8192) = 16
25933 read(16, "", 8192) = 0
25933 read(16, "", 8192) = 0
25933 close(16) = 0
------------------------------------------------------------------------
[2010-07-12 16:35:46] pajoye@php.net
The scan of each element of the paths happen anyway, whether the paths
contain symlinks or not. Check the code TSRM/ for a deeper explanation.
------------------------------------------------------------------------
[2010-07-12 15:57:54] v dot damore at gmail dot com
@pajoye; as is described in "Actual result" part of this bug, first time
PHP engine check filepath there is a full scan of all directories at
least 4
times before cache the result, this behavior anyway cannot scale in a so
large environment.
@rasmus: this is very interesting, I can consider upgrade to 5.3 in
order to avoid this behavior.
I know this is an extrema ratio: may I disable symlinks support from PHP
engine in order to avoid this behavior?
Is there an answer regarding the increase of realpath_cache_size
realpath_cache_ttl?
------------------------------------------------------------------------
[2010-07-12 15:36:10] rasmus@php.net
And like I said, we have made this more efficient in PHP 5.3 because we
now cache
the partial paths separately. You should see a performance improvement
going to
5.3.
------------------------------------------------------------------------
[2010-07-12 15:32:33] pajoye@php.net
Again, it does it once and only once per path. When it does it, it
checks each element of a path (and cache each of them too).
------------------------------------------------------------------------
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
http://bugs.php.net/bug.php?id=52312
--
Edit this bug report at http://bugs.php.net/bug.php?id=52312&edit=1