Subject: | abs_path() errouneously returning undef because lstat() sets errno to EINVAL |
Hello,
I am seeing several systems behaving strangely (details below) in
regards to abs_path. I am still tracing this out and wanted to post the
details for reference and in case one of you gurus see what the cause
could be right off hand, thanks!
[ -- Working server -- ]
# perl -MCwd -Mstrict -wle 'my $etc = Cwd::abs_path("/etc");if (defined
$etc) { print "Defined: $etc" } else { print "Undefined"; }'
Defined: /etc
[ -- Affected server -- ]
# perl -MCwd -Mstrict -wle 'my $etc = Cwd::abs_path("/etc");if (defined
$etc) { print "Defined: $etc" } else { print "Undefined"; }'
Undefined
[ -- lower level -- ]
If I add debug output before and after line 156 in Cwd.xs like so:
printf("DEBUG Before %d %s\n", errno, resolved);
struct stat sb;
if (lstat(resolved, &sb) != 0) {
printf("DEBUG After %d %s\n", errno, resolved);
if (errno == ENOENT && p == NULL) {
errno = serrno;
return (resolved);
}
return (NULL);
}
printf("DEBUG I got past the return(NULL) above");
and rebuild it, then we now see that errno was changed from ENOENT to
EINVAL and thus the return(NULL) is triggered:
# perl -I. -I./blib/arch -MCwd -Mstrict -wle 'my $etc =
Cwd::abs_path("/etc");if (defined $etc) { print "Defined: $etc" } else
{ print "Undefined"; }'
DEBUG Before 2 /etc
DEBUG After 22 /etc
Undefined
It is the same if we change lstat() to PerlLIO_lstat()
[ -- misc info -- ]
Both servers are
• 64 bit
• CentOS release 5.5 (Final)
• Using Cwd 3.33 (but installing older version results in the same
behavior)
• have “d_lstat” set to “define”
Working server:
• This is perl, v5.8.8 built for x86_64-linux
• from RPM: perl.x86_64 4:5.8.8-32.el5_5.2
(another affected server had perl.x86_64 4:5.8.8-27.el5 installed)
Affected server:
• This is perl, v5.8.8 built for x86_64-linux-thread-multi
• from RPM: perl.x86_64 4:5.8.8-32.el5_5.1
(another affected server had perl.x86_64 4:5.8.8-27.el5 installed)
A diff of the output of:
perl -MConfig -e 'for $k (sort keys %Config) { print
"$k:$Config{$k}\n"; }'
on each box is attached as sorted_config.diff
Subject: | sorted_config.diff |
Message body is not shown because it is too large.