# How to find a bug: is_link troubles

- Thread: https://externals.io/message/29132
- Original archive: https://news-web.php.net/php.internals/29132
- Started by Arnold Daniels on 2007-05-02T19:27:04+00:00
- Messages: 30
- Page 1 of 2: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/29132.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #29132 — Arnold Daniels — 2007-05-02T19:27:04+00:00

URL: https://externals.io/message/29132#29132

Hi,

I've got a bug with is_link and lstats. Any symlinks not created in the 
current session, will not be read. This only occurs in the Apache 2 SAPI 
version, not in the CLI version.

Script:
/<?
    $symlink = '/tmp/link-test';
    if (file_exists($symlink)) unlink($symlink);
    symlink('/tmp/pear', $symlink);
    echo (file_exists($symlink) ? is_link($symlink) ? "Correct" : 
"ERROR" : "Couldn't create the link"), "<br/>\n";

    $symlink = '/tmp/link-persist';
    if (!file_exists($symlink)) symlink('/tmp/pear', $symlink);
    echo (file_exists($symlink) ? is_link($symlink) ? "Correct" : 
"ERROR" : "Couldn't create the link"), "<br/>\n";
?>/

First run:
/    Correct
    Correct
/
Second run:
/    Correct
    ERROR/

Next runs:
/    Correct
    ERROR

/I've recently start using the daily snapshots op PHP, but I also tried 
it on version 5.2.1, which shows the same result. It used to work just 
fine, so I'm sure this isn't the expected result. I've recently upgraded 
from Ubuntu Edgy (6.10) to Feisty (7.04), with kernel and apache update, 
so I believe that the problem is related to that.

I've straced the process (see attachment), but I can't pinpoint the 
problem. This is a big issue for me, can anyone point me in the right 
direction to find the source of this problem.

Thanks,
Arnold

---

## #29138 — Tijnema ! — 2007-05-03T09:28:12+00:00

URL: https://externals.io/message/29132#29138 · In reply to: #29132

> Hi,
>
> I've got a bug with is_link and lstats. Any symlinks not created in the
> current session, will not be read. This only occurs in the Apache 2 SAPI
> version, not in the CLI version.
>
> Script:
> <?
>     $symlink = '/tmp/link-test';
>     if (file_exists($symlink)) unlink($symlink);
>     symlink('/tmp/pear', $symlink);
>     echo (file_exists($symlink) ? is_link($symlink) ? "Correct" : "ERROR" :
> "Couldn't create the link"), "<br/>\n";
>
>     $symlink = '/tmp/link-persist';
>     if (!file_exists($symlink)) symlink('/tmp/pear', $symlink);
>     echo (file_exists($symlink) ? is_link($symlink) ? "Correct" : "ERROR" :
> "Couldn't create the link"), "<br/>\n";
> ?>
>
> First run:
>     Correct
>     Correct
>
> Second run:
>     Correct
>     ERROR
>
> Next runs:
>     Correct
>     ERROR
>
> I've recently start using the daily snapshots op PHP, but I also tried it on
> version 5.2.1, which shows the same result. It used to work just fine, so
> I'm sure this isn't the expected result. I've recently upgraded from Ubuntu
> Edgy (6.10) to Feisty (7.04), with kernel and apache update, so I believe
> that the problem is related to that.
>
> I've straced the process (see attachment), but I can't pinpoint the problem.
> This is a big issue for me, can anyone point me in the right direction to
> find the source of this problem.
>
> Thanks,
> Arnold
>
<snip>

Well, I've also tested this code, and it does work fine. BUT if
/tmp/pear doesn't exists, what i had at first, then file_exists
returns false, because file_exists follows symlinks, and the symlink
pointed to nothing. So if you're sure that $symlink is a link, then it
might be better to check it with is_link.

Also, the is_link function is cached, so you might want to add one or
more `clearstatcache()` in your script.

I checked your strace also, but it doesn't look like there's a bug.
But I've never studied on the PHP core so....

Well, if above doesn't help you, then one of the "real experts" needs
to look at it :)

Tijnema

---

## #29389 — Arnold Daniels — 2007-05-10T17:17:18+00:00

URL: https://externals.io/message/29132#29389 · In reply to: #29138

Hi again,

Thanks for your reply. I think perhaps I've not been totally clear on my 
last e-mail. The directory does exist. If this dir or symlink would not 
exist, the code would have outputted "Couldn't create the link". The 
fact that is goes well right after the symlink is just created, is 
indeed the cause of the stat cache.

But the actual problem is that the symlink is not recognized as a 
symlink. It seems to be dereferenced by functions like 'lstat', 
'is_link' and 'filetype'. And that isn't supposed to happen.

The problem has probably something to do with my system in combination 
with apache/php. So I guess reporting it as a bug won't do, because it 
will simply be filed under 'works here'. If anybody has any clue what is 
going on here, please let me know. For the record I've updated to CVS 
snapshot of May 10, 2007 14:30 GMT, but it didn't work with older 
version as well.

Let me give another example, with which I hope I can make the problem 
clearer.

------------
Script:
<?
    $symlink = '/tmp/link-test';
    $target = '/tmp/pear';
   
    if (!file_exists($target)) trigger_error("Target '$target' does not 
exist", E_USER_ERROR);
    if (file_exists($symlink) && !unlink($symlink)) trigger_error("Could 
not delete '$symlink'", E_USER_ERROR);

    symlink($target, $symlink);
    `clearstatcache()`;

    /* This should output 'link' */
    echo filetype($symlink), "\n";
   
    /* This should output 'link' */
    echo is_link($symlink) ? 'link' : 'not a link', "\n";

    /* This should output 'differ' */
    echo lstat($symlink) === stat($target) ? 'same' : 'differ';
?>

Expected:
   link
   link
   differ

Actual:
   dir
   not a link
   same

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

Thanks for any help,

Arnold






Tijnema ! wrote:
> 
> > […]
> <snip>
>
> Well, I've also tested this code, and it does work fine. BUT if
> /tmp/pear doesn't exists, what i had at first, then file_exists
> returns false, because file_exists follows symlinks, and the symlink
> pointed to nothing. So if you're sure that $symlink is a link, then it
> might be better to check it with is_link.
>
> Also, the is_link function is cached, so you might want to add one or
> more `clearstatcache()` in your script.
>
> I checked your strace also, but it doesn't look like there's a bug.
> But I've never studied on the PHP core so....
>
> Well, if above doesn't help you, then one of the "real experts" needs
> to look at it :)
>
> Tijnema

---

## #29700 — Arnold Daniels — 2007-05-23T20:37:42+00:00

URL: https://externals.io/message/29132#29700 · In reply to: #29138

Hi,

I've posted this problem some time ago, but never got a real answer and 
it is still bothering me a lot.

My problem is that PHP does not recognize a symlink as a symlink. It 
seems to be dereferenced by functions like 'lstat', 'is_link' and 
'filetype'. And that isn't supposed to happen.

The bug http://bugs.php.net/bug.php?id=17128 describes my problem 
exactly, but is marked as bogus. Well this problem sure isn't bogus for 
me. I'm having this problem, since I've updated from Ubuntu Edgy to 
Feisty. Before that all worked fine.
Please note that I've not installed PHP from a repository, but I build 
the latest CVS version of PHP 5 regularly myself. Also this problem only 
occurs in the Apache 2 SAPI, not in the CLI version.

Let me give an example, to make the problem clear.

------------
<?
    $symlink = '/tmp/link-test';
    $target = '/tmp/pear';

    if (!file_exists($target)) trigger_error("Target '$target' does not
exist", E_USER_ERROR);
    if (file_exists($symlink) && !unlink($symlink)) trigger_error("Could
not delete '$symlink'", E_USER_ERROR);

    symlink($target, $symlink);
    `clearstatcache()`;

    /* This should output 'link' */
    echo filetype($symlink), "\n";

    /* This should output 'link' */
    echo is_link($symlink) ? 'link' : 'not a link', "\n";

    /* This should output 'differ' */
    echo lstat($symlink) === stat($target) ? 'same' : 'differ';
?>

Expected:
   link
   link
   differ

Actual:
   dir
   not a link
   same

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

I understand that if I post this as a bug, it is tested, can't be 
reproduced and marked as bogus. Therefore, I could appreciate it if 
someone could please point me towards a way to pinpoint the problem. 
I've run a strace already, but can't notice anything weird.

Thanks for any help,

Arnold

---

## #29702 — Rasmus Lerdorf — 2007-05-23T21:54:02+00:00

URL: https://externals.io/message/29132#29702 · In reply to: #29700

So, would this be Ubuntu 7.04?  I happen to have one of those boxes
sitting here:

5:52pm ubuntu:~> mkdir /tmp/pear
5:52pm ubuntu:~> cat /etc/issue
Ubuntu 7.04 \n \l

5:52pm ubuntu:~> uname -a
Linux ubuntu 2.6.20-15-server #2 SMP Sun Apr 15 07:41:34 UTC 2007 i686
GNU/Linux

5:52pm ubuntu:~> php p
link
link
differ

5:52pm ubuntu:~> l /tmp | grep link
lrwxrwxrwx  1 rasmus rasmus    9 2007-05-23 17:52 link-test -> /tmp/pear/

The 'p' script is just a copy of paste of your script from this message.

-Rasmus

Arnold Daniels wrote:
> Hi,
> 
> I've posted this problem some time ago, but never got a real answer and
> it is still bothering me a lot.
> 
> My problem is that PHP does not recognize a symlink as a symlink. It
> seems to be dereferenced by functions like 'lstat', 'is_link' and
> 'filetype'. And that isn't supposed to happen.
> 
> The bug http://bugs.php.net/bug.php?id=17128 describes my problem
> exactly, but is marked as bogus. Well this problem sure isn't bogus for
> me. I'm having this problem, since I've updated from Ubuntu Edgy to
> Feisty. Before that all worked fine.
> Please note that I've not installed PHP from a repository, but I build
> the latest CVS version of PHP 5 regularly myself. Also this problem only
> occurs in the Apache 2 SAPI, not in the CLI version.
> 
> Let me give an example, to make the problem clear.
> 
> ------------
> <?
>    $symlink = '/tmp/link-test';
>    $target = '/tmp/pear';
> 
>    if (!file_exists($target)) trigger_error("Target '$target' does not
> exist", E_USER_ERROR);
>    if (file_exists($symlink) && !unlink($symlink)) trigger_error("Could
> not delete '$symlink'", E_USER_ERROR);
> 
>    symlink($target, $symlink);
>    `clearstatcache()`;
> 
>    /* This should output 'link' */
>    echo filetype($symlink), "\n";
> 
>    /* This should output 'link' */
>    echo is_link($symlink) ? 'link' : 'not a link', "\n";
> 
>    /* This should output 'differ' */
>    echo lstat($symlink) === stat($target) ? 'same' : 'differ';
> ?>
> 
> Expected:
>   link
>   link
>   differ
> 
> Actual:
>   dir
>   not a link
>   same
> 
> ------------
> 
> I understand that if I post this as a bug, it is tested, can't be
> reproduced and marked as bogus. Therefore, I could appreciate it if
> someone could please point me towards a way to pinpoint the problem.
> I've run a strace already, but can't notice anything weird.
> 
> Thanks for any help,
> 
> Arnold

---

## #29703 — Brian Moon — 2007-05-23T22:01:41+00:00

URL: https://externals.io/message/29132#29703 · In reply to: #29702

Rasmus Lerdorf wrote:
> 5:52pm ubuntu:~> php p

I think he said "Also this problem only occurs in the Apache 2 SAPI, not 
in the CLI version."

=)

-- 

Brian Moon
Senior Developer
------------------------------
http://dealnews.com/
It's good to be cheap =)

---

## #29705 — Rasmus Lerdorf — 2007-05-23T22:10:53+00:00

URL: https://externals.io/message/29132#29705 · In reply to: #29703

Brian Moon wrote:
> Rasmus Lerdorf wrote:
> > […]
> 
> I think he said "Also this problem only occurs in the Apache 2 SAPI, not
> in the CLI version."

Works fine under Apache1.  I don't have Apache2 handy on this box.  But
I can't see this being affected by the SAPI in any way other than user
permissions and/or some sort of SELinux restriction.  As in, things
external to PHP itself.

So, if someone who knows their way around strace can reproduce this
problem and show me the series of syscalls and their exit status, we can
probably figure out what is happening.  I'm about 90% sure this is not a
PHP problem, but rather a system configuration problem.

-Rasmus

---

## #29706 — Scott MacVicar — 2007-05-23T22:15:38+00:00

URL: https://externals.io/message/29132#29706 · In reply to: #29700

I'm getting similar results from a RHEL 4 box we have here, its running 
5.2.3-dev.

scott@scarlet [/tmp] # cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4 (Nahant Update 4)

scott@scarlet [~] # uname -a
Linux scarlet 2.6.9-42.0.2.ELsmp #1 SMP Thu Aug 17 18:00:32 EDT 2006 
i686 i686 i386 GNU/Linux

scott@scarlet [/tmp] # php test.php
dir
not a link
same

strace for the during execution is.

lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
readlink("/tmp/link-test", "/tmp/pear", 4096) = 9
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
write(1, "dir", 3dir)                      = 3
write(1, "\n", 1)                       = 1
write(1, "not a link", 10not a link)              = 10
write(1, "\n", 1)                       = 1
time(NULL)                              = 1179958429
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
write(1, "same", 4same)                     = 4

Scott

Arnold Daniels wrote:
> Hi,
> 
> I've posted this problem some time ago, but never got a real answer and 
> it is still bothering me a lot.
> 
> My problem is that PHP does not recognize a symlink as a symlink. It 
> seems to be dereferenced by functions like 'lstat', 'is_link' and 
> 'filetype'. And that isn't supposed to happen.
> 
> The bug http://bugs.php.net/bug.php?id=17128 describes my problem 
> exactly, but is marked as bogus. Well this problem sure isn't bogus for 
> me. I'm having this problem, since I've updated from Ubuntu Edgy to 
> Feisty. Before that all worked fine.
> Please note that I've not installed PHP from a repository, but I build 
> the latest CVS version of PHP 5 regularly myself. Also this problem only 
> occurs in the Apache 2 SAPI, not in the CLI version.
> 
> Let me give an example, to make the problem clear.
> 
> ------------
> <?
>    $symlink = '/tmp/link-test';
>    $target = '/tmp/pear';
> 
>    if (!file_exists($target)) trigger_error("Target '$target' does not
> exist", E_USER_ERROR);
>    if (file_exists($symlink) && !unlink($symlink)) trigger_error("Could
> not delete '$symlink'", E_USER_ERROR);
> 
>    symlink($target, $symlink);
>    `clearstatcache()`;
> 
>    /* This should output 'link' */
>    echo filetype($symlink), "\n";
> 
>    /* This should output 'link' */
>    echo is_link($symlink) ? 'link' : 'not a link', "\n";
> 
>    /* This should output 'differ' */
>    echo lstat($symlink) === stat($target) ? 'same' : 'differ';
> ?>
> 
> Expected:
>   link
>   link
>   differ
> 
> Actual:
>   dir
>   not a link
>   same
> 
> ------------
> 
> I understand that if I post this as a bug, it is tested, can't be 
> reproduced and marked as bogus. Therefore, I could appreciate it if 
> someone could please point me towards a way to pinpoint the problem. 
> I've run a strace already, but can't notice anything weird.
> 
> Thanks for any help,
> 
> Arnold

---

## #29707 — Rasmus Lerdorf — 2007-05-23T22:28:44+00:00

URL: https://externals.io/message/29132#29707 · In reply to: #29706

lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/link-test", 0xbff229ec)   = -1 ENOENT (No such file or
directory)
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
symlink("/tmp/pear", "/tmp/link-test")  = 0
lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
write(1, "link", 4link)                     = 4
write(1, "\n", 1
)                       = 1
write(1, "link", 4link)                     = 4
write(1, "\n", 1
)                       = 1
stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
write(1, "differ", 6differ)                   = 6


Scott MacVicar wrote:
> I'm getting similar results from a RHEL 4 box we have here, its running
> 5.2.3-dev.
> 
> scott@scarlet [/tmp] # cat /etc/redhat-release
> Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
> 
> scott@scarlet [~] # uname -a
> Linux scarlet 2.6.9-42.0.2.ELsmp #1 SMP Thu Aug 17 18:00:32 EDT 2006
> i686 i686 i386 GNU/Linux
> 
> scott@scarlet [/tmp] # php test.php
> dir
> not a link
> same
> 
> strace for the during execution is.
> 
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0

That means /tmp/link-test exists already, otherwise lstat returns -1.
Here is what I see if the link already exists when I run my script:

access("/tmp/pear", F_OK)               = 0
access("/tmp/link-test", F_OK)          = 0
unlink("/tmp/link-test")                = 0
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/link-test", 0xbff229ec)   = -1 ENOENT (No such file or
directory)
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
symlink("/tmp/pear", "/tmp/link-test")  = 0
lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
write(1, "link", 4link)                     = 4
write(1, "\n", 1
)                       = 1
write(1, "link", 4link)                     = 4
write(1, "\n", 1
)                       = 1
stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
write(1, "differ", 6differ)                   = 6

So did you leave out those access() calls, and did they fail, or did the
 `unlink()` fail perhaps?

-Rasmus

---

## #29708 — Scott MacVicar — 2007-05-23T22:34:25+00:00

URL: https://externals.io/message/29132#29708 · In reply to: #29707

Miscopied, a full strace is:

lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
access("/tmp/pear", F_OK)               = 0
time(NULL)                              = 1179959483
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
readlink("/tmp/link-test", "/tmp/pear", 4096) = 9
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
access("/tmp/pear", F_OK)               = 0
unlink("/tmp/link-test")                = 0
time(NULL)                              = 1179959483
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/link-test", 0xbff2137c)   = -1 ENOENT (No such file or 
directory)
time(NULL)                              = 1179959483
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
symlink("/tmp/pear", "/tmp/link-test")  = 0
time(NULL)                              = 1179959483
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
readlink("/tmp/link-test", "/tmp/pear", 4096) = 9
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
write(1, "dir", 3dir)                      = 3
write(1, "\n", 1
)                       = 1
write(1, "not a link", 10not a link)              = 10
write(1, "\n", 1
)                       = 1
time(NULL)                              = 1179959483
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
write(1, "same", 4same)                     = 4

SELinux is disabled on the box.

Scott

Rasmus Lerdorf wrote:
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/link-test", 0xbff229ec)   = -1 ENOENT (No such file or
> directory)
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> symlink("/tmp/pear", "/tmp/link-test")  = 0
> lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> write(1, "differ", 6differ)                   = 6
> 
> 
> Scott MacVicar wrote:
> > […]
> 
> That means /tmp/link-test exists already, otherwise lstat returns -1.
> Here is what I see if the link already exists when I run my script:
> 
> access("/tmp/pear", F_OK)               = 0
> access("/tmp/link-test", F_OK)          = 0
> unlink("/tmp/link-test")                = 0
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/link-test", 0xbff229ec)   = -1 ENOENT (No such file or
> directory)
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> symlink("/tmp/pear", "/tmp/link-test")  = 0
> lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> write(1, "differ", 6differ)                   = 6
> 
> So did you leave out those access() calls, and did they fail, or did the
> `unlink()` fail perhaps?
> 
> -Rasmus

---

## #29709 — Brian Moon — 2007-05-23T22:43:12+00:00

URL: https://externals.io/message/29132#29709 · In reply to: #29707

Works as expected on my Mac (no strace on my Mac).  On my Gentoo 64-bit 
  server, I get the wrong data from Apache2 and CLI.  On my 32-bit 
Gentoo server, without Apache 2, I get the correct answer from apache 
and cli.  On my 32-bit Gentoo server with Apache 2 I get a wrong answer 
from Apache and cli.

We build our PHP on these servers with the same options via emerge.  The 
only difference is Apache 2.  What the hell?


# uname -a
Linux proxy1 2.6.18-gentoo-r6 #1 SMP Thu Feb 8 07:32:31 EST 2007 x86_64 
Dual-Core AMD Opteron(tm) Processor 2210 AuthenticAMD GNU/Linux

# php foobar.php
dir
not a link
same

lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
access("/tmp/pear", F_OK)               = 0
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
readlink("/tmp/link-test", "/tmp/pear", 4096) = 9
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
access("/tmp/pear", F_OK)               = 0
unlink("/tmp/link-test")                = 0
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/link-test", 0x7fff3f48fb70) = -1 ENOENT (No such file or 
directory)
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
symlink("/tmp/pear", "/tmp/link-test")  = 0
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
readlink("/tmp/link-test", "/tmp/pear", 4096) = 9
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x2b906b634000
write(1, "dir", 3dir)                      = 3
write(1, "\n", 1
)                       = 1
write(1, "not a link", 10not a link)              = 10
write(1, "\n", 1
)                       = 1
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
write(1, "same", 4same)                     = 4


32-bit Gentoo however acts as expected.

$ uname -a
Linux deadpool 2.6.11-gentoo-r6 #1 SMP Thu Apr 14 07:52:09 EDT 2005 i686 
Intel(R) Xeon(TM) CPU 3.20GHz GenuineIntel GNU/Linux

  php test.php
link
link
differ


access("/tmp/pear", F_OK)               = 0
access("/tmp/link-test", F_OK)          = 0
unlink("/tmp/link-test")                = 0
time(NULL)                              = 1179959743
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=14416, ...}) = 0
lstat64("/tmp/link-test", 0xbfff5e4c)   = -1 ENOENT (No such file or 
directory)
time(NULL)                              = 1179959743
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=14416, ...}) = 0
lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
symlink("/tmp/pear", "/tmp/link-test")  = 0
lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 
0) = 0xb78b1000
write(1, "link", 4link)                     = 4
write(1, "\n", 1
)                       = 1
write(1, "link", 4link)                     = 4
write(1, "\n", 1
)                       = 1
stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
write(1, "differ", 6differ)                   = 6


Rasmus Lerdorf wrote:
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/link-test", 0xbff229ec)   = -1 ENOENT (No such file or
> directory)
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> symlink("/tmp/pear", "/tmp/link-test")  = 0
> lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> write(1, "differ", 6differ)                   = 6
> 
> 
> Scott MacVicar wrote:
> > […]
> 
> That means /tmp/link-test exists already, otherwise lstat returns -1.
> Here is what I see if the link already exists when I run my script:
> 
> access("/tmp/pear", F_OK)               = 0
> access("/tmp/link-test", F_OK)          = 0
> unlink("/tmp/link-test")                = 0
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/link-test", 0xbff229ec)   = -1 ENOENT (No such file or
> directory)
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> symlink("/tmp/pear", "/tmp/link-test")  = 0
> lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> write(1, "differ", 6differ)                   = 6
> 
> So did you leave out those access() calls, and did they fail, or did the
> `unlink()` fail perhaps?
> 
> -Rasmus
> 


-- 

Brian Moon
Senior Developer
------------------------------
http://dealnews.com/
It's good to be cheap =)

---

## #29710 — Rasmus Lerdorf — 2007-05-23T22:49:06+00:00

URL: https://externals.io/message/29132#29710 · In reply to: #29709

Which filesystems is /tmp on on the various boxes?  tmpfs related perhaps?

-Rasmus

Brian Moon wrote:
> Works as expected on my Mac (no strace on my Mac).  On my Gentoo 64-bit
>  server, I get the wrong data from Apache2 and CLI.  On my 32-bit Gentoo
> server, without Apache 2, I get the correct answer from apache and cli. 
> On my 32-bit Gentoo server with Apache 2 I get a wrong answer from
> Apache and cli.
> 
> We build our PHP on these servers with the same options via emerge.  The
> only difference is Apache 2.  What the hell?
> 
> 
> # uname -a
> Linux proxy1 2.6.18-gentoo-r6 #1 SMP Thu Feb 8 07:32:31 EST 2007 x86_64
> Dual-Core AMD Opteron(tm) Processor 2210 AuthenticAMD GNU/Linux
> 
> # php foobar.php
> dir
> not a link
> same
> 
> lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> access("/tmp/pear", F_OK)               = 0
> lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
> readlink("/tmp/link-test", "/tmp/pear", 4096) = 9
> lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> access("/tmp/pear", F_OK)               = 0
> unlink("/tmp/link-test")                = 0
> lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat("/tmp/link-test", 0x7fff3f48fb70) = -1 ENOENT (No such file or
> directory)
> lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> symlink("/tmp/pear", "/tmp/link-test")  = 0
> lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
> readlink("/tmp/link-test", "/tmp/pear", 4096) = 9
> lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
> = 0x2b906b634000
> write(1, "dir", 3dir)                      = 3
> write(1, "\n", 1
> )                       = 1
> write(1, "not a link", 10not a link)              = 10
> write(1, "\n", 1
> )                       = 1
> lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
> lstat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> stat("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> write(1, "same", 4same)                     = 4
> 
> 
> 32-bit Gentoo however acts as expected.
> 
> $ uname -a
> Linux deadpool 2.6.11-gentoo-r6 #1 SMP Thu Apr 14 07:52:09 EDT 2005 i686
> Intel(R) Xeon(TM) CPU 3.20GHz GenuineIntel GNU/Linux
> 
>  php test.php
> link
> link
> differ
> 
> 
> access("/tmp/pear", F_OK)               = 0
> access("/tmp/link-test", F_OK)          = 0
> unlink("/tmp/link-test")                = 0
> time(NULL)                              = 1179959743
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=14416, ...}) = 0
> lstat64("/tmp/link-test", 0xbfff5e4c)   = -1 ENOENT (No such file or
> directory)
> time(NULL)                              = 1179959743
> lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=14416, ...}) = 0
> lstat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
> symlink("/tmp/pear", "/tmp/link-test")  = 0
> lstat64("/tmp/link-test", {st_mode=S_IFLNK|0777, st_size=9, ...}) = 0
> fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0xb78b1000
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> write(1, "link", 4link)                     = 4
> write(1, "\n", 1
> )                       = 1
> stat64("/tmp/pear", {st_mode=S_IFDIR|0755, st_size=72, ...}) = 0
> write(1, "differ", 6differ)                   = 6
> 
> 
> Rasmus Lerdorf wrote:
> > […]

---

## #29711 — Brian Moon — 2007-05-24T02:22:57+00:00

URL: https://externals.io/message/29132#29711 · In reply to: #29710

Rasmus Lerdorf wrote:
> Which filesystems is /tmp on on the various boxes?  tmpfs related perhaps?

On all my systems, /tmp is just part of / which is ReiserFS.

-- 

Brian Moon
Senior Developer
------------------------------
http://dealnews.com/
It's good to be cheap =)

---

## #29748 — Arnold Daniels — 2007-05-25T12:12:34+00:00

URL: https://externals.io/message/29132#29748 · In reply to: #29711

Hi,

Sorry I didn't react sooner. I was out of the office.

I'm running ReiserFS as well.

arnold@arnold-laptop:~$ mount
/dev/sda3 on / type reiserfs (rw,notail)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.20-15-generic/volatile type tmpfs (rw)
/dev/sda5 on /home type reiserfs (rw)
/dev/sda6 on /xen-images type reiserfs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

arnold@arnold-laptop:~$ apache2 -v
Server version: Apache/2.2.3
Server built:   Jan 15 2007 18:14:50

If I need to send anything else, please let me know.

Best regards,
Arnold


Brian Moon wrote:
> Rasmus Lerdorf wrote:
> > […]
>
> On all my systems, /tmp is just part of / which is ReiserFS.

---

## #29759 — Tijnema — 2007-05-25T16:17:41+00:00

URL: https://externals.io/message/29132#29759 · In reply to: #29710

> Which filesystems is /tmp on on the various boxes?  tmpfs related perhaps?
>
> -Rasmus

Nice idea, but I don't think it's a problem there, I think it's a
configuration problem. I've build my own linux, and so I have all
configuration like I want.
I'm running php-5.2.3RC1 as Apache 2.2.3 module.
I've split up my USB stick in a few file systems, and they worked all
for me, except for msdos&vfat file systems, as they don't support
symlinks.
Test results here:
http://86.86.80.41/fs_test.php
and source for the test is here:
http://86.86.80.41/fs_test.phps

Tijnema
>
> Brian Moon wrote:
> > […]

---

## #29761 — Rasmus Lerdorf — 2007-05-25T17:08:00+00:00

URL: https://externals.io/message/29132#29761 · In reply to: #29759

Tijnema wrote:
> 
> > […]
> 
> Nice idea, but I don't think it's a problem there, I think it's a
> configuration problem. I've build my own linux, and so I have all
> configuration like I want.
> I'm running php-5.2.3RC1 as Apache 2.2.3 module.
> I've split up my USB stick in a few file systems, and they worked all
> for me, except for msdos&vfat file systems, as they don't support
> symlinks.
> Test results here:
> http://86.86.80.41/fs_test.php
> and source for the test is here:
> http://86.86.80.41/fs_test.phps

Mount options then perhaps?  There is a "nosymlink" mount option which
would certainly cause this.

-Rasmus

---

## #29763 — Arnold Daniels — 2007-05-25T17:50:50+00:00

URL: https://externals.io/message/29132#29763 · In reply to: #29761

Hi again,

No, the symlinks work fine in the shell and with all other applications. 
Also I haven't mounted with any options other than 'notail'. Please have 
a look at the e-mail I've send a few hours ago.

arnold@arnold-laptop:~$ mount
/dev/sda3 on / type reiserfs (rw,notail)
.....

Best regards,
Arnold


Rasmus Lerdorf wrote:
> Tijnema wrote:
>   
> > […]
>
> Mount options then perhaps?  There is a "nosymlink" mount option which
> would certainly cause this.
>
> -Rasmus

---

## #29764 — Oliver Block — 2007-05-25T18:26:11+00:00

URL: https://externals.io/message/29132#29764 · In reply to: #29763

Hi,

how about

gdb php


Regards,

Oliver

Am Freitag, 25. Mai 2007 19:50 schrieb Arnold Daniels:
> Hi again,
>
> No, the symlinks work fine in the shell and with all other applications.
> Also I haven't mounted with any options other than 'notail'. Please have
> a look at the e-mail I've send a few hours ago.
>
> arnold@arnold-laptop:~$ mount
> /dev/sda3 on / type reiserfs (rw,notail)
> .....
>
> Best regards,
> Arnold
>
> Rasmus Lerdorf wrote:
> > […]

---

## #29765 — Tijnema — 2007-05-25T18:30:08+00:00

URL: https://externals.io/message/29132#29765 · In reply to: #29764

> Hi,
>
> how about
>
> gdb php
>
>
> Regards,
>
> Oliver

He said that the problem only occured with the Apache 2 SAPI, so the
gdb is for the PHP CLI.

Tijnema
>
> Am Freitag, 25. Mai 2007 19:50 schrieb Arnold Daniels:
> > […]

---

## #29771 — Tijnema — 2007-05-25T20:11:18+00:00

URL: https://externals.io/message/29132#29771 · In reply to: #29763

> Hi again,
>
> No, the symlinks work fine in the shell and with all other applications.
> Also I haven't mounted with any options other than 'notail'. Please have a
> look at the e-mail I've send a few hours ago.
>
> arnold@arnold-laptop:~$ mount
> /dev/sda3 on / type reiserfs (rw,notail)
> .....
>
> Best regards,
> Arnold

Quite weird, I have mounted with notail too now, just to make sure the
problem isn't there, but I can't reproduce your problem. I also have
Apache 2.2.3, and I tested it with PHP-5.2.3RC1, PHP-5.2.2RC2,
PHP-5.2.1 and an old CVS of PHP6. No problems at all.

Tijnema
>
>
>
> Rasmus Lerdorf wrote:
> Tijnema wrote:

> 

> Which filesystems is /tmp on on the various boxes? tmpfs
> related
perhaps?

-Rasmus

> Nice idea, but I don't think it's a problem there, I think it's
> a
configuration problem. I've build my own linux, and so I have
> all
configuration like I want.
I'm running php-5.2.3RC1 as Apache 2.2.3
> module.
I've split up my USB stick in a few file systems, and they worked
> all
for me, except for msdos&vfat file systems, as they don't
> support
symlinks.
Test results here:
http://86.86.80.41/fs_test.php
and
> source for the test is here:
http://86.86.80.41/fs_test.phps

> Mount options then perhaps? There is a "nosymlink" mount option which
would
> certainly cause this.

-Rasmus

---

## #29775 — Oliver Block — 2007-05-25T21:57:27+00:00

URL: https://externals.io/message/29132#29775 · In reply to: #29765

Am Freitag, 25. Mai 2007 20:30 schrieben Sie:
> He said that the problem only occured with the Apache 2 SAPI, so the
> gdb is for the PHP CLI.

You can also use it with apache2 sapi. But then you need to do  (Debian)

gdb /usr/sbin/apache2

and then

run -k start

If you set a break to zif_... that should work.

Regards,

Oliver




>
> Tijnema
>
> > […]

---

## #29782 — Arnold Daniels — 2007-05-25T22:30:36+00:00

URL: https://externals.io/message/29132#29782 · In reply to: #29775

Hi again,

I've used strace and after simplifying the test and looking at it more 
closely, I did see something strange. The apache process does an lstat, 
reads the link and then does an lstat on real file.

Perhaps this was already recognized by others, but I didn't see a 
confirmation of this in any of the e-mails. If I need to run gdb please 
let me know, though it might be a bit to complicated for me a php 
internals newbie (I can make my own simple extensions, but the knowledge 
ends there).

<?php
    echo `getmypid()`;
    `flush()`;
    sleep(10);
  
    /* This should output link */
    echo filetype('/tmp/test-php-bug-simple-link'), "\n";
?>


When I run the code in the command line (strace php simple.php 2> 
/tmp/php-bug.cli.trace):

....
read(3, "<?php\n    echo `getmypid()`;\n    f"..., 8192) = 153
read(3, "", 4096)                       = 0
read(3, "", 8192)                       = 0
close(3)                                = 0
munmap(0xb7590000, 4096)                = 0
write(1, "9469", 4)                     = 4
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({10, 0}, {10, 0})             = 0
lstat64("/tmp/test-php-bug-simple-link", {st_mode=S_IFLNK|0777, 
st_size=19, ...}) = 0
write(1, "link", 4)                     = 4
write(1, "\n", 1)                       = 1
close(2)                                = 0
close(1)                                = 0
close(0)                                = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
exit_group(0)                           = ?
Process 9469 detached


But when I run the same code in Apache (strace -p8753 2> 
/tmp/php-bug.apache2.trace):

Process 8753 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>) = 0
time(NULL)                              = 1180130951
lstat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=1160, ...}) = 0
lstat64("/tmp/test-php-bug-simple-link", {st_mode=S_IFLNK|0777, 
st_size=19, ...}) = 0
readlink("/tmp/test-php-bug-simple-link", "test-php-bug-simple", 4096) = 19
lstat64("/tmp/test-php-bug-simple", {st_mode=S_IFREG|0644, st_size=12, 
...}) = 0
lstat64("/tmp/test-php-bug-simple", {st_mode=S_IFREG|0644, st_size=12, 
...}) = 0
time(NULL)                              = 1180130951
stat64("/", {st_mode=S_IFDIR|0755, st_size=600, ...}) = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
writev(22, [{"5\r\n", 3}, {"file\n", 5}, {"\r\n", 2}, {"0\r\n\r\n", 5}], 
4) = 15
read(22, "", 8000)                      = 0
write(14, "127.0.0.1 - - [26/May/2007:00:09"..., 181) = 181
gettimeofday({1180130951, 718114}, NULL) = 0
shutdown(22, 1 /* send */)              = 0
poll([{fd=22, events=POLLIN, revents=POLLIN|POLLHUP}], 1, 2000) = 1
read(22, "", 512)                       = 0
close(22)                               = 0
read(4, 0xbff61af7, 1)                  = -1 EAGAIN (Resource 
temporarily unavailable)
accept(3,  <unfinished ...>
Process 8753 detached


Best regards,
Arnold



Oliver Block wrote:
> Am Freitag, 25. Mai 2007 20:30 schrieben Sie:
>   
> > […]
>
> You can also use it with apache2 sapi. But then you need to do  (Debian)
>
> gdb /usr/sbin/apache2
>
> and then
>
> run -k start
>
> If you set a break to zif_... that should work.
>
> Regards,
>
> Oliver
>
>
>
>
>   
> > […]

---

## #29784 — Oliver Block — 2007-05-26T00:08:17+00:00

URL: https://externals.io/message/29132#29784

Hi Arnold,

Am Samstag, 26. Mai 2007 00:28 schrieben Sie:
> If I need to run gdb please let me know, 

I did a gdb and on my system (debian, CLI). filetype returns 'dir' as well.

my code was php -r 'filetype("/tmp/link-test");'

Where /tmp/link-test is a link to a directory /tmp/pear.

This is some of the output:

I set a breakpoint to php_stat. You can see the parameters passed to it.

Breakpoint 1, php_stat (filename=0xb78f4584 "/tmp/link-test",
    filename_length=14, type=8, return_value=0xb78f5044, tsrm_ls=0x87b8018)
    at /usr/local/src/php-5.2.2/ext/standard/filestat.c:730

Some of the steps beginning at line 851 (standard/filestat.c, php_stat())

851             switch (type) {
(gdb)
881                     if (S_ISLNK(ssb.sb.st_mode)) {
(gdb)
884                     switch(ssb.sb.st_mode & S_IFMT) {
(gdb)
887                     case S_IFDIR: RETURN_STRING("dir", 1);
(gdb)
981     }

This is a print of ssb 

(gdb) p ssb
$2 = {sb = {st_dev = 769, __pad1 = 0, st_ino = 66149, st_mode = 16877,
    st_nlink = 2, st_uid = 0, st_gid = 0, st_rdev = 0, __pad2 = 0,
    st_size = 4096, st_blksize = 4096, st_blocks = 8, st_atim = {
      tv_sec = 1180124961, tv_nsec = 0}, st_mtim = {tv_sec = 1180124961,
      tv_nsec = 0}, st_ctim = {tv_sec = 1180124961, tv_nsec = 0},
    __unused4 = 0, __unused5 = 0}}


Regards,

Oliver

---

## #29785 — Rasmus Lerdorf — 2007-05-26T00:29:46+00:00

URL: https://externals.io/message/29132#29785 · In reply to: #29784

Oliver Block wrote:
> Hi Arnold,
> 
> Am Samstag, 26. Mai 2007 00:28 schrieben Sie:
> > […]
> 
> I did a gdb and on my system (debian, CLI). filetype returns 'dir' as well.
> 
> my code was php -r 'filetype("/tmp/link-test");'
> 
> Where /tmp/link-test is a link to a directory /tmp/pear.
> 
> This is some of the output:
> 
> I set a breakpoint to php_stat. You can see the parameters passed to it.
> 
> Breakpoint 1, php_stat (filename=0xb78f4584 "/tmp/link-test",
>     filename_length=14, type=8, return_value=0xb78f5044, tsrm_ls=0x87b8018)
>     at /usr/local/src/php-5.2.2/ext/standard/filestat.c:730
> 
> Some of the steps beginning at line 851 (standard/filestat.c, php_stat())
> 
> 851             switch (type) {
> (gdb)
> 881                     if (S_ISLNK(ssb.sb.st_mode)) {
> (gdb)
> 884                     switch(ssb.sb.st_mode & S_IFMT) {
> (gdb)
> 887                     case S_IFDIR: RETURN_STRING("dir", 1);
> (gdb)
> 981     }

Right, so the (ssb.sb.st_mode & S_IFMT) is S_IFDIR which is basically
the OS telling us that it is a directory.  I don't see what we can do if
the OS is not telling us the right thing.  The filestat code is a bit
convoluted trying to deal with lots of strange operating systems, but
this part of it seems pretty clear.

-Rasmus

---

## #29786 — Oliver Block — 2007-05-26T00:35:59+00:00

URL: https://externals.io/message/29132#29786 · In reply to: #29785

Am Samstag, 26. Mai 2007 02:29 schrieben Sie:
> Right, so the (ssb.sb.st_mode & S_IFMT) is S_IFDIR which is basically
> the OS telling us that it is a directory.  I don't see what we can do if
> the OS is not telling us the right thing.  The filestat code is a bit
> convoluted trying to deal with lots of strange operating systems, but
> this part of it seems pretty clear.

OK. But let me mention (without knowing the source code of stat) that 

stat --format=%F /tmp/link-test

returns 'symbolic link'

So there must be different methods to find out!?

Regards,

Oliver

---

Next page: https://externals.io/message/29132.md?page=2
