develooper Front page | perl.perl5.porters | Postings from December 2018

[perl #133709] in-place edit does not replace files duringnon-global cleanup

From:
Tony Cook
Date:
December 3, 2018 22:48
Subject:
[perl #133709] in-place edit does not replace files duringnon-global cleanup
Message ID:
rt-4.0.24-17722-1543877283-133.133709-75-0@perl.org
# New Ticket Created by  Tony Cook 
# Please include the string:  [perl #133709]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133709 >



This is a bug report for perl from tony@develop-help.com,
generated with the help of perlbug 1.41 running under perl 5.29.6.


-----------------------------------------------------------------
[Please describe your issue here]

[perl #133659] reported a problem where the in-place edit input file
wasn't replaced with the output file during global clean-up.

That specific problem was fixed[1] but a more difficult to solve case
like:

 sub foo {
   local (*ARGV, *ARGVOUT);
   @ARGV = @_;
   my $d = do { local $/; <> };
   $d =~ s/FAILED/OK/ or die;
   print $d;
 }
 eval { foo("somefile") };

doesn't replace the file on apparent success.

To solve that problem we need to be able to detect whether the current
unwinding is due to die or normal clean up, and there's no current
mechanism for that.

https://rt.perl.org/Ticket/Display.html?id=133659#txn-1595418

includes an attempt at adding such a mechanism, but fails its own
tests.

Since the reported problem was fixed, I'll be closing the original
ticket, this ticket preserves the more difficult case.

[1] https://rt.perl.org/Ticket/Display.html?id=133659#txn-1596249

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.29.6:

Configured by tony at Mon Dec  3 16:00:04 AEDT 2018.

Summary of my perl5 (revision 5 version 29 subversion 6) configuration:
  Commit id: bf5c7c7dda5ab51eb76dfb8282ec8fa20cea9363
  Platform:
    osname=linux
    osvers=4.9.0-8-amd64
    archname=x86_64-linux
    uname='linux mars 4.9.0-8-amd64 #1 smp debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 gnulinux '
    config_args='-des -Dusedevel -DDEBUGGING -Doptimize=-O0 -g'
    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 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O0 -g'
    cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='6.3.0 20170516'
    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/gcc/x86_64-linux-gnu/6/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 /lib64 /usr/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.24.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.24'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O0 -g -L/usr/local/lib -fstack-protector-strong'


---
@INC for perl 5.29.6:
    lib
    /usr/local/lib/perl5/site_perl/5.29.6/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.29.6
    /usr/local/lib/perl5/5.29.6/x86_64-linux
    /usr/local/lib/perl5/5.29.6

---
Environment for perl 5.29.6:
    HOME=/home/tony
    LANG=en_AU.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/tony/perl5/perlbrew/bin:/home/tony/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    PERLBREW_BASHRC_VERSION=0.43
    PERLBREW_HOME=/home/tony/.perlbrew
    PERLBREW_MANPATH=
    PERLBREW_PATH=/home/tony/perl5/perlbrew/bin
    PERLBREW_ROOT=/home/tony/perl5/perlbrew
    PERLBREW_VERSION=0.67
    PERL_BADLANG (unset)
    SHELL=/bin/bash




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About