develooper Front page | perl.perl5.porters | Postings from January 2014

[perl #121105] During a system(), unquoted Perl vars are evaluated _after_ the fork() call

Thread Next
From:
perlbug-followup
Date:
January 30, 2014 12:35
Subject:
[perl #121105] During a system(), unquoted Perl vars are evaluated _after_ the fork() call
Message ID:
rt-4.0.18-16370-1390936538-1602.121105-75-0@perl.org
# New Ticket Created by   
# Please include the string:  [perl #121105]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=121105 >


This is a bug report for perl from gpiero@rm-rf.it,
generated with the help of perlbug 1.39 running under perl 5.18.2.


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

Hi,

I've recently noticed the following behaviour:

$ perl -l
print $$;
system 'echo', "$$";
system 'echo', $$;
32480
32480
32488

The last pid printed (from the system() with unquoted $$) is the pid of 
the child process, not the one of the parent.

 From my tests, this behaviour is in place since 5.16.0. With previous 
versions, all the three statements 'correctly' (in DWIM sense) displayed 
the parent's pid.

At first I thought it was shelling out even if it shouldn't, but both a 
strace and a quick test dismissed this hypothesis:

$ perl -l
system 'echo $$ $PWD';
system 'echo', $$, $PWD;
800 /home/gpiero
801 

Attached you can find the system-evaluate-vars-after-fork.t test file 
that I used against various perl versions.
Versions[0] from 5.8.9 to 5.14.4 passed all the three tests.
Versions[0] from 5.16.0 to 5.19.8 failed the first test (but passed the 
other two).

system-evaluate-vars-after-fork-portable.t should be an equivalent test 
file, but without non core dependencies and possibly portable, suitable 
for being included in the test suite, as being suggested on #p5p.

Thanks,
Gian Piero.

[0] Some minor releases missing, but the latest release of every major 
version has been tested.

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

Configured by gpiero at Sat Jan 25 17:34:32 CET 2014.

Summary of my perl5 (revision 5 version 18 subversion 2) configuration:
    
   Platform:
     osname=linux, osvers=3.12-1-amd64, archname=x86_64-linux
     uname='linux caimano 3.12-1-amd64 #1 smp debian 3.12.6-2 (2013-12-29) x86_64 gnulinux '
     config_args='-de -Dprefix=/home/gpiero/perl5/perlbrew/perls/perl-5.18.2 -Aeval:scriptdir=/home/gpiero/perl5/perlbrew/perls/perl-5.18.2/bin'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
     use64bitint=define, use64bitall=define, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
     optimize='-O2',
     cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
     ccversion='', gccversion='4.8.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='double', nvsize=8, Off_t='off_t', lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
     libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
     libs=-lnsl -ldl -lm -lcrypt -lutil -lc
     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
     libc=, 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'

Locally applied patches:
     

---
@INC for perl 5.18.2:
     /home/gpiero/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux
     /home/gpiero/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2
     /home/gpiero/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/x86_64-linux
     /home/gpiero/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2
     .

---
Environment for perl 5.18.2:
     HOME=/home/gpiero
     LANG=en_US.UTF-8
     LANGUAGE=en_US:en
     LC_COLLATE=C
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=/home/gpiero/bin:/home/gpiero/perl5/perlbrew/bin:/home/gpiero/perl5/perlbrew/perls/perl-5.18.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
     PERLBREW=command perlbrew
     PERLBREW_BASHRC_VERSION=0.67
     PERLBREW_HOME=/home/gpiero/.perlbrew
     PERLBREW_MANPATH=/home/gpiero/perl5/perlbrew/perls/perl-5.18.2/man
     PERLBREW_PATH=/home/gpiero/perl5/perlbrew/bin:/home/gpiero/perl5/perlbrew/perls/perl-5.18.2/bin
     PERLBREW_PERL=perl-5.18.2
     PERLBREW_ROOT=/home/gpiero/perl5/perlbrew
     PERLBREW_VERSION=0.67
     PERL_BADLANG (unset)
     SHELL=/bin/bash


Thread Next


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