ID:               35791
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jgmtfia at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: Linux
 PHP Version:      5CVS-2006-01-03 (snap)
 New Comment:

Configure PHP with this configure line:

# rm config.cache ; ./configure --disable-all --disable-cgi
--enable-debug
# make 

Then test, if it fails -> send your main/php_config.h to me.


Previous Comments:
------------------------------------------------------------------------

[2006-01-03 17:19:45] jgmtfia at gmail dot com

I want to ensure that I have made my point clear.  I have made a
simplier example, and have included an edited strace of PHP built from
yesterdays source.

The test:
<?php
`touch A; ln -s A C`;

echo "Checking A.\n";
if(!file_exists('A')){
    echo "A does not exist.\n";
    exit;
}

echo "Checking C.\n";
if(!file_exists('C')){
    echo "C does not exist.\n";
    exit;
}

echo "Unlinking C.\n";
unlink('C');

clearstatcache();

echo "Checking C: ";
if(file_exists('C'))
    echo "(FAIL) exists\n";
?>

The ouput: 
Checking A.
Checking C.
Unlinking C.
Checking C: (FAIL) exists

The edited strace:
write(1, "Checking A.\n", 12)
lstat64("/home", ...) = 0
lstat64("/home/user", ...) = 0
lstat64("/home/user/x", ...) = 0
lstat64("/home/user/x/A", ...) = 0
access("/home/user/x/A", F_OK) = 0

write(1, "Checking C.\n", 12)
lstat64("/home", ...) = 0
lstat64("/home/user", = 0
lstat64("/home/user/x", = 0
lstat64("/home/user/x/C", = 0
readlink("/home/user/x/C", "A", 4096) = 1
lstat64("/home/user/x/A", ...) = 0
access("/home/user/x/A", F_OK) = 0

write(1, "Unlinking C.\n", 13) = 13
unlink("/home/user/x/C") = 0
write(1, "Checking C: ", 12) = 12
***ERROR SHOULD BE "/home/user/x/C" BELOW ***
access("/home/user/x/A", F_OK) = 0
***END***
write(1, "(FAIL) exists\n", 14) = 14

So the question is why is PHP calling access("/home/user/x/A") when the
code calls file_exists('C')?

Also note that if the file_exists('C') call is removed from the start
code, the code then executes correctly.
<?php
`touch A; ln -s A C`;

echo "Unlinking C.\n";
unlink('C');

clearstatcache();

echo "Checking C: ";
if(file_exists('C'))
    echo "(FAIL) exists\n";

?>

I don't know if it would be the operating system that would cause PHP
to access("/home/user/x/A") when I call file_exists('C').

debain php4.3.10-15 does pass the test and there are no lstat64 or
readlink calls.

write(1, "Checking A.\n", 12) = 12
access("A", F_OK) = 0
write(1, "Checking C.\n", 12) = 12
access("C", F_OK) = 0
write(1, "Unlinking C.\n", 13) = 13
unlink("C") = 0
write(1, "Checking C: ", 12) = 12
access("C", F_OK) = -1 ENOENT (No such file or directory)

------------------------------------------------------------------------

[2006-01-02 20:23:03] [EMAIL PROTECTED]

Works fine with working OS. Debian "stable" apparently isn't one of
these. (tested with RHEL4 and FC4)


------------------------------------------------------------------------

[2006-01-02 18:02:08] jgmtfia at gmail dot com

I have trimmed the strace output, but I can provide full output if
necessary.

It works in with PHP 4.3.10-15 on debian stable:
access("C", F_OK)                       = 0
pipe([3, 7])                            = 0
vfork()                                 = 10336
--- SIGCHLD (Child exited) @ 0 (0) ---
close(7)                                = 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb79d8000
read(3, "lrwxr-xr-x  1 1 Jan  2 09:48 C -"..., 4096) = 36
read(3, "", 4096)                       = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
waitpid(10336, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 10336
munmap(0xb79d8000, 4096)                = 0
fstat64(1, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb79d8000
write(1, "File \'C\' exists:\n\t\tlrwxr-xr-x  1"..., 56) = 56
unlink("C")                             = 0
pipe([3, 7])                            = 0
vfork()                                 = 10338
close(7)                                = 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb79d7000
read(3, "ls: ", 4096)                   = 4
--- SIGCHLD (Child exited) @ 0 (0) ---
read(3, "C: No such file or directory\n", 4096) = 29
read(3, "", 4096)                       = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
waitpid(10338, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0) = 10338
munmap(0xb79d7000, 4096)                = 0
write(1, "Deleted \'C\'\n\t\tls: C: No such fil"..., 48) = 48
access("C", F_OK)                       = -1 ENOENT (No such file or
directory)
write(1, "(PASS) PHP sees the file as dele"..., 37) = 37

With php5.1-200601021330:
The link /home/user/C gets translated to /home/user/x/A and what should
be accesses to /home/user/C are accesses to /home/user/A as seen in the
second last line of the following strace.

lstat64("/home", {st_mode=S_IFDIR|S_ISGID|0775, st_size=4096, ...}) =
0
lstat64("/home/user", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/home/user/x", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/home/user/x/C", {st_mode=S_IFLNK|0755, st_size=1, ...}) = 0
readlink("/home/user/x/C", "A", 4096) = 1
lstat64("/home/user/x/A", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
access("/home/user/x/A", F_OK)        = 0
pipe([3, 4])                            = 0
vfork()                                 = 10221
close(4)                                = 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap2(NULL, 0, PROT_READ, MAP_SHARED, 3, 0) = -1 ENODEV (No such
device)
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
read(3, "lrwxr-xr-x  1 1 Jan  2 09:23 C -"..., 8192) = 36
read(3, "", 8192)                       = 0
close(3)                                = 0
waitpid(10221, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 10221
--- SIGCHLD (Child exited) @ 0 (0) ---
fstat64(1, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7fe8000
write(1, "File \'C\' exists:\n\t\tlrwxr-xr-x  1"..., 56) = 56
unlink("/home/user/x/C")              = 0
pipe([3, 4])                            = 0
vfork()                                 = 10223
close(4)                                = 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap2(NULL, 0, PROT_READ, MAP_SHARED, 3, 0) = -1 ENODEV (No such
device)
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
read(3, "ls: ", 8192)                   = 4
read(3, "C", 8192)                      = 1
read(3, ": No such file or directory", 8192) = 27
read(3, "\n", 8192)                     = 1
read(3, "", 8192)                       = 0
close(3)                                = 0
waitpid(10223, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0) = 10223
--- SIGCHLD (Child exited) @ 0 (0) ---
write(1, "Deleted \'C\'\n\t\tls: C: No such fil"..., 48) = 48
time(NULL)                              = 1136219020
access("/home/user/x/A", F_OK)        = 0
write(1, "(FAIL) File \'C\' deleted as seen "..., 40) = 40

------------------------------------------------------------------------

[2006-01-02 17:15:11] [EMAIL PROTECTED]

You can strace the script and see what files are actually being
accessed.

------------------------------------------------------------------------

[2006-01-02 17:10:27] jgmtfia at gmail dot com

I tested the "lastest" version (php5.1-200601021330) on debian stable
and it failed.  Over the holidays I tried 5.1.1 with debian testing and
it passed.

A summary of results:
4.3.10 - debian stable - pass
5.1.0b3 - debian stable - fail
5.1.0 - debian stable - fail
5.1.1 - debian stable - fail
5.1.1 - debian testing - pass
php5.1-200601021330 - debian stable - fail
5.1.2RC2-dev - SUSE Linux 10 x86_64 - pass

Common to all failures is Debian stable.  Do you have any suggestions
on how to approach finding what is causing the fault?

------------------------------------------------------------------------

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/35791

-- 
Edit this bug report at http://bugs.php.net/?id=35791&edit=1

Reply via email to