Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abs_path() errouneously returning undef because lstat() sets errno to EINVAL #11137

Closed
p5pRT opened this issue Feb 17, 2011 · 9 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Feb 17, 2011

Migrated from rt.perl.org#84338 (status was 'resolved')

Searchable as RT84338$

@p5pRT
Copy link
Author

p5pRT commented Feb 17, 2011

From dmuey@cpan.org

Created by dmuey@cpan.org

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 (the server this perlbug was sent from)​:
  • 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 to https://rt.cpan.org/Ticket/Display.html?id=65379

Perl Info

Flags:
    category=library
    severity=high

This perlbug was built using Perl v5.8.8 in the Red Hat build system.
It is being executed now by Perl v5.8.8 - Mon Jun  7 21:25:07 EDT 2010.

Site configuration information for perl v5.8.8:

Configured by Red Hat, Inc. at Mon Jun  7 21:25:07 EDT 2010.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.18-53.el5, archname=x86_64-linux-thread-multi
    uname='linux builder10.centos.org 2.6.18-53.el5 #1 smp mon nov 12 02:14:55 est 2007 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Dversion=5.8.8 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Dprivlib=/usr/lib/perl5/5.8.8 -Dsitelib=/usr/lib/perl5/site_perl/5.8.8 -Dvendorlib=/usr/lib/perl5/vendor_perl/5.8.8 -Darchlib=/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi -Dsitearch=/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi -Darchname=x86_64-linux-thread-multi -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dinc_version_list=5.8.7 5.8.6 5.8.5 -Dscriptdir=/usr/bin'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=define uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='4.1.2 20080704 (Red Hat 4.1.2-48)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =''
    libpth=/usr/local/lib64 /lib64 /usr/lib64
    libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

Locally applied patches:
    


@INC for perl v5.8.8:
    /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl
    /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl
    /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi
    /usr/lib/perl5/5.8.8
    .


Environment for perl v5.8.8:
    HOME=/root
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/dell/srvadmin/bin:/opt/dell/srvadmin/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Feb 20, 2011

From @cpansprout

On Thu Feb 17 09​:07​:03 2011, dmuey wrote​:

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 (the server this perlbug was sent from)​:
• 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)

I cannot produce this on Mac OS X. Does the affected server remain right
itself if you switch to a non-threaded build?

@p5pRT
Copy link
Author

p5pRT commented Feb 20, 2011

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Feb 22, 2011

From dmuey@cpan.org

I cannot produce this on Mac OS X.

Right, it is only reproducible on certain machines.

Does the affected server remain right
itself if you switch to a non-threaded build?

As a matter of fact it does, nice!

So it appears to be a (64bit) threading issue …

@p5pRT
Copy link
Author

p5pRT commented Feb 24, 2011

From webmaster@simplemood.com

I cannot produce this on Mac OS X.

Right, it is only reproducible on certain machines.

Does the affected server remain right
itself if you switch to a non-threaded build?

As a matter of fact it does, nice!

So it appears to be a (64bit) threading issue …

@p5pRT
Copy link
Author

p5pRT commented Sep 7, 2013

From @jkeenan

On Thu Feb 24 00​:43​:58 2011, webmaster@​simplemood.com wrote​:

I cannot produce this on Mac OS X.

Right, it is only reproducible on certain machines.

Does the affected server remain right
itself if you switch to a non-threaded build?

As a matter of fact it does, nice!

So it appears to be a (64bit) threading issue …

Tonight I built a threaded perl on the Dromedary server, at blead, and
then attempted to reproduce the problem the OP reported in early 2011.

#####
sh ./Configure -des -Dusedevel -Dusethreads -Duseithreads
make -j8
#####
./perl -I./lib -MCwd -Mstrict -wle 'my $etc = Cwd​::abs_path("/etc");if
(defined $etc) { print "Defined​: $etc" } else { print "Undefined"; }'
#####
Defined​: /etc
#####

Granted, I did not configure with the long list of arguments the OP did.
But this tends not to support the presence of a problem.

Can anyone confirm? Is this ticket closable?

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2013

From @jkeenan

On Fri Sep 06 20​:09​:25 2013, jkeenan wrote​:

On Thu Feb 24 00​:43​:58 2011, webmaster@​simplemood.com wrote​:

I cannot produce this on Mac OS X.

Right, it is only reproducible on certain machines.

Does the affected server remain right
itself if you switch to a non-threaded build?

As a matter of fact it does, nice!

So it appears to be a (64bit) threading issue …

Tonight I built a threaded perl on the Dromedary server, at blead, and
then attempted to reproduce the problem the OP reported in early 2011.

#####
sh ./Configure -des -Dusedevel -Dusethreads -Duseithreads
make -j8
#####
./perl -I./lib -MCwd -Mstrict -wle 'my $etc = Cwd​::abs_path("/etc");if
(defined $etc) { print "Defined​: $etc" } else { print "Undefined"; }'
#####
Defined​: /etc
#####

Granted, I did not configure with the long list of arguments the OP did.
But this tends not to support the presence of a problem.

Can anyone confirm? Is this ticket closable?

Thank you very much.
Jim Keenan

We have not heard from the original poster in 2-3/4 years. No one has provided evidence that this is not fixed in blead.

So I am taking this ticket for the purpose of closing it within 7 days unless someone objects.

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2013

From @jkeenan

On Sun Nov 24 09​:50​:35 2013, jkeenan wrote​:

We have not heard from the original poster in 2-3/4 years. No one has
provided evidence that this is not fixed in blead.

So I am taking this ticket for the purpose of closing it within 7 days
unless someone objects.

Closing as per schedule.

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2013

@jkeenan - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant