Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.92k stars 551 forks source link

Cwd.pm fast_abs_path is sometimes inconsistent and wrong #17369

Open jrw opened 4 years ago

jrw commented 4 years ago

This is a bug report for perl from jrw32982@yahoo.com, generated with the help of perlbug 1.41 running under perl 5.30.1.


[Please describe your issue here]

Script to reproduce:

  rm -f a b || exit 1
  PERL=/opt/perl5.30.1/bin/perl
  $PERL -v | grep version

  echo; echo ln -s b a; ln -s b a
  $PERL -MCwd=abs_path      -le 'print "abs(   a): ",      abs_path   "a"'
  $PERL -MCwd=fast_abs_path -le 'print "fast(  a): ", fast_abs_path   "a"'
  $PERL -MCwd=abs_path      -le 'print "abs( ./a): ",      abs_path "./a"'
  $PERL -MCwd=fast_abs_path -le 'print "fast(./a): ", fast_abs_path "./a"'

  echo; echo touch b; touch b

  $PERL -MCwd=abs_path      -le 'print "abs(   a): ",      abs_path   "a"'
  $PERL -MCwd=fast_abs_path -le 'print "fast(  a): ", fast_abs_path   "a"'
  $PERL -MCwd=abs_path      -le 'print "abs( ./a): ",      abs_path "./a"'
  $PERL -MCwd=fast_abs_path -le 'print "fast(./a): ", fast_abs_path "./a"'

  rm -f a b

abs_path() is correct. fast_abs_path() should match it in all cases. I purposely did not include -w, in order to make the output clearer. Output:

This is perl 5, version 30, subversion 1 (v5.30.1) built for x86_64-linux

  ln -s b a
  abs(   a): /home/jrw32982/junk/b
  fast(  a):
  abs( ./a): /home/jrw32982/junk/b
  fast(./a):

  touch b
  abs(   a): /home/jrw32982/junk/b
  fast(  a): /home/jrw32982/junk/a
  abs( ./a): /home/jrw32982/junk/b
  fast(./a): /home/jrw32982/junk/b

[Please do not change anything below this line]


Flags: category=library severity=medium module=Cwd

Site configuration information for perl 5.30.1:

Configured by jrw32982 at Fri Nov 22 13:02:19 EST 2019.

Summary of my perl5 (revision 5 version 30 subversion 1) configuration:

Platform: osname=linux osvers=3.10.0-862.el7.x86_64 archname=x86_64-linux uname='linux trvlapp2459 3.10.0-862.el7.x86_64 #1 smp wed mar 21 18:14:51 edt 2018 x86_64 x86_64 x86_64 gnulinux ' config_args='-des -Dprefix=/opt/perl5.30.1' hint=recommended useposix=true d_sigaction=define useithreads=undef usemultiplicity=undef use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n default_inc_excludes_dot=define bincompat5005=undef Compiler: cc='cc' ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2' optimize='-O2' cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include' ccversion='' gccversion='4.8.5 20150623 (Red Hat 4.8.5-4)' gccosandvers='' intsize=4 longsize=8 ptrsize=8 doublesize=8 byteorder=12345678 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=16 longdblkind=3 ivtype='long' ivsize=8 nvtype='double' nvsize=8 Off_t='off_t' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries: ld='cc' ldflags =' -fstack-protector-strong -L/usr/local/lib' libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64 libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.17.so so=so useshrplib=false libperl=libperl.a gnulibc_version='2.17' Dynamic Linking: dlsrc=dl_dlopen.xs dlext=so d_dlsymun=undef ccdlflags='-Wl,-E' cccdlflags='-fPIC' lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'


@INC for perl 5.30.1: /home/jrw32982/std/lib/perl /opt/perl5.30.1/lib/site_perl/5.30.1/x86_64-linux /opt/perl5.30.1/lib/site_perl/5.30.1 /opt/perl5.30.1/lib/5.30.1/x86_64-linux /opt/perl5.30.1/lib/5.30.1


Environment for perl 5.30.1: HOME=/home/jrw32982 LANG=en_US.UTF-8 LANGUAGE (unset) LC_ALL=C LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/jrw32982/std/bin:/home/jrw32982/bin:/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/etc:. PERL5LIB=/home/jrw32982/std/lib/perl PERL_BADLANG (unset) SHELL=/bin/bash

jkeenan commented 4 years ago

This is a bug report for perl from jrw32982@yahoo.com, generated with the help of perlbug 1.41 running under perl 5.30.1.

[Please describe your issue here]

Script to reproduce:

rm -f a b || exit 1
PERL=/opt/perl5.30.1/bin/perl
$PERL -v | grep version

echo; echo ln -s b a; ln -s b a
$PERL -MCwd=abs_path      -le 'print "abs(   a): ",      abs_path   "a"'
$PERL -MCwd=fast_abs_path -le 'print "fast(  a): ", fast_abs_path   "a"'
$PERL -MCwd=abs_path      -le 'print "abs( ./a): ",      abs_path "./a"'
$PERL -MCwd=fast_abs_path -le 'print "fast(./a): ", fast_abs_path "./a"'

echo; echo touch b; touch b

$PERL -MCwd=abs_path      -le 'print "abs(   a): ",      abs_path   "a"'
$PERL -MCwd=fast_abs_path -le 'print "fast(  a): ", fast_abs_path   "a"'
$PERL -MCwd=abs_path      -le 'print "abs( ./a): ",      abs_path "./a"'
$PERL -MCwd=fast_abs_path -le 'print "fast(./a): ", fast_abs_path "./a"'

rm -f a b

abs_path() is correct. fast_abs_path() should match it in all cases. I purposely did not include -w, in order to make the output clearer. Output:

This is perl 5, version 30, subversion 1 (v5.30.1) built for x86_64-linux

  ln -s b a
  abs(   a): /home/jrw32982/junk/b
  fast(  a):
  abs( ./a): /home/jrw32982/junk/b
  fast(./a):

  touch b
  abs(   a): /home/jrw32982/junk/b
  fast(  a): /home/jrw32982/junk/a
  abs( ./a): /home/jrw32982/junk/b
  fast(./a): /home/jrw32982/junk/b

Possibly related to: https://github.com/Perl/perl5/issues/14887 https://github.com/Perl/perl5/issues/11931

jrw commented 4 years ago

Related (Cwd.pm bugs), but I don't think the same thing.  This new bug is about fast_abs_path working differently than abs_path on nonexistent files which are targets of symlinks, instead of canonicalizing them the way abs_path does.

On Monday, December 16, 2019, 11:11:30 PM EST, James E Keenan <notifications@github.com> wrote:  

This is a bug report for perl from jrw32982@yahoo.com, generated with the help of perlbug 1.41 running under perl 5.30.1.

[Please describe your issue here]

Script to reproduce: rm -f a b || exit 1 PERL=/opt/perl5.30.1/bin/perl $PERL -v | grep version

echo; echo ln -s b a; ln -s b a $PERL -MCwd=abs_path -le 'print "abs( a): ", abs_path "a"' $PERL -MCwd=fast_abs_path -le 'print "fast( a): ", fast_abs_path "a"' $PERL -MCwd=abs_path -le 'print "abs( ./a): ", abs_path "./a"' $PERL -MCwd=fast_abs_path -le 'print "fast(./a): ", fast_abs_path "./a"'

echo; echo touch b; touch b

$PERL -MCwd=abs_path -le 'print "abs( a): ", abs_path "a"' $PERL -MCwd=fast_abs_path -le 'print "fast( a): ", fast_abs_path "a"' $PERL -MCwd=abs_path -le 'print "abs( ./a): ", abs_path "./a"' $PERL -MCwd=fast_abs_path -le 'print "fast(./a): ", fast_abs_path "./a"'

rm -f a b

abs_path() is correct. fast_abs_path() should match it in all cases. I purposely did not include -w, in order to make the output clearer. Output:

This is perl 5, version 30, subversion 1 (v5.30.1) built for x86_64-linux ln -s b a abs( a): /home/jrw32982/junk/b fast( a): abs( ./a): /home/jrw32982/junk/b fast(./a):

touch b abs( a): /home/jrw32982/junk/b fast( a): /home/jrw32982/junk/a abs( ./a): /home/jrw32982/junk/b fast(./a): /home/jrw32982/junk/b

Possibly related to:

14887

11931

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.