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

misplaced inplace-edit warning #14644

Open
p5pRT opened this issue Apr 10, 2015 · 1 comment
Open

misplaced inplace-edit warning #14644

p5pRT opened this issue Apr 10, 2015 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Apr 10, 2015

Migrated from rt.perl.org#124278 (status was 'new')

Searchable as RT124278$

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2015

From zefram@fysh.org

Created by zefram@fysh.org

If perl fails to open a file for <ARGV>, it bizarrely performs an
additional stat operation before emitting its warning message​:

$ strace /opt/perl/bin/perl -e 'print <ARGV>' t0
[...]
open("t0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("t0", 0x2b09a0cbd280) = -1 ENOENT (No such file or directory)
write(2, "Can't open t0​: No such file or d"..., 55Can't open t0​: No such file or directory at -e line 1.
) = 55
[...]

This stat doesn't add anything to the reporting of the open error.
In fact, it's also misdirected​: if the command-line argument contains
metacharacters that affect open then the stat goes to the unprocessed
argument, not to the path on which open was attempted. That can even
yield a different error, and the error that is reported is still the one
from the open, but the error message misleadingly gives the unprocessed
argument​:

$ mkdir t1
$ mkdir -m 0 ' t1'
$ strace /opt/perl/bin/perl -e 'print <ARGV>' ' t1/b'
[...]
open("t1/b", O_RDONLY) = -1 ENOENT (No such file or directory)
stat(" t1/b", 0x2b4a5ba98280) = -1 EACCES (Permission denied)
write(2, "Can't open t1/b​: No such file o"..., 58Can't open t1/b​: No such file or directory at -e line 1.
) = 58
[...]

The stat is performed by some code near the end of Perl_nextargv()
in doio.c, which thinks it's doing something about in-place editing,
even though that's not actually involved here. Some very misleading
error messages can result​:

$ mkfifo ' t2'
$ strace /opt/perl/bin/perl -e 'print <ARGV>' ' t2'
[...]
open("t2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat(" t2", {st_mode=S_IFIFO|0664, st_size=0, ...}) = 0
write(2, "Can't do inplace edit​: t2 is no"..., 63Can't do inplace edit​: t2 is not a regular file at -e line 1.
) = 63
[...]

In this case the error message complains about ' t2' being non-regular,
which indeed it is, but the failure of the open has nothing to do with
that file, and nothing to do with in-place editing.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.20.2:

Configured by root at Fri Mar 20 11:06:52 UTC 2015.

Summary of my perl5 (revision 5 version 20 subversion 2) configuration:
   
  Platform:
    osname=linux, osvers=3.2.0-4-amd64, archname=x86_64-linux-ld
    uname='linux ukmcwzefram.photobox.priv 3.2.0-4-amd64 #1 smp debian 3.2.60-1+deb7u3 x86_64 gnulinux '
    config_args='-des -Duseshrplib -Duse64bitint -Duselongdouble -Uusethreads -Uusemultiplicity -Dprefix=/opt/perl-5.20.2 -Dsiteprefix=/opt/perl-5.20.2 -Dvendorprefix=/opt/perl-5.20.2/vendor -Doptimize=-ggdb -O3 -fbranch-target-load-optimize -fgcse-las -fgcse-sm -fipa-pta -floop-block -floop-interchange -floop-strip-mine -fmodulo-sched -fomit-frame-pointer -freorder-blocks-and-partition -fsched-spec-load -fsched-spec-load-dangerous -ftree-loop-distribution -Dcccdlflags=-fPIC -O3 -pipe'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-ggdb -O3 -fbranch-target-load-optimize -fgcse-las -fgcse-sm -fipa-pta -floop-block -floop-interchange -floop-strip-mine -fmodulo-sched -fomit-frame-pointer -freorder-blocks-and-partition -fsched-spec-load -fsched-spec-load-dangerous -ftree-loop-distribution',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.7.2', 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='long double', nvsize=16, Off_t='off_t', lseeksize=8
    alignbytes=16, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.17.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.17'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/perl-5.20.2/lib/5.20.2/x86_64-linux-ld/CORE'
    cccdlflags='-fPIC -O3 -pipe', lddlflags='-shared -ggdb -O3 -fbranch-target-load-optimize -fgcse-las -fgcse-sm -fipa-pta -floop-block -floop-interchange -floop-strip-mine -fmodulo-sched -fomit-frame-pointer -freorder-blocks-and-partition -fsched-spec-load -fsched-spec-load-dangerous -ftree-loop-distribution -L/usr/local/lib -fstack-protector'



@INC for perl 5.20.2:
    /opt/perl-5.20.2/lib/site_perl/5.20.2/x86_64-linux-ld
    /opt/perl-5.20.2/lib/site_perl/5.20.2
    /opt/perl-5.20.2/vendor/lib/vendor_perl/5.20.2/x86_64-linux-ld
    /opt/perl-5.20.2/vendor/lib/vendor_perl/5.20.2
    /opt/perl-5.20.2/lib/5.20.2/x86_64-linux-ld
    /opt/perl-5.20.2/lib/5.20.2
    .


Environment for perl 5.20.2:
    HOME=/home/zefram
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/zefram/pub/x86_64-unknown-linux-gnu/bin:/home/zefram/pub/common/bin:/usr/bin:/bin:/usr/local/bin:/usr/games:/opt/babelhttpd-2.2.26/bin:/opt/babelhttpd-2.4.7/bin:/opt/geoip/bin:/opt/httpd/bin:/opt/perl/bin
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh

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

2 participants