Skip Menu |
Report information
Id: 122703
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: felipe [at] felipegasper.com
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: medium
Type: core
Perl Version: 5.14.4
Fixed In: (no value)

Attachments


From: felipe [...] felipegasper.com
Subject: chmod() doesn't populate a local()ed $!
To: perlbug [...] perl.org
Date: Thu, 04 Sep 2014 12:43:13 -0500
Download (untitled) / with headers
text/plain 6.5k
This is a bug report for perl from felipe@felipegasper.com, generated with the help of perlbug 1.39 running under perl 5.14.4. ----------------------------------------------------------------- [Please describe your issue here] perl -MFile::Temp -e'my ($fh, $path) = File::Temp::tempfile(); close $fh; local ($!); my $ok = chmod( 0111, $fh ); print "ok? [$ok] err? [$!/$^E]"' The above breaks on every Perl version that I've tried: 5.14.4/Linux, 5.18.2/Mac, and 5.20.0/Mac. If you take out the "local ($!);", then it populates $! as you'd expect. [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=medium --- Site configuration information for perl 5.14.4: Configured by cPanel at Thu Jul 10 15:51:11 CDT 2014. Summary of my perl5 (revision 5 version 14 subversion 4) configuration: Platform: osname=linux, osvers=2.6.32-358.23.2.el6.i686, archname=i386-linux-64int uname='linux rpmb-32-centos-6 2.6.32-358.23.2.el6.i686 #1 smp wed oct 16 17:21:31 utc 2013 i686 i686 i386 gnulinux ' config_args='-des -Dusedevel -Darchname=i386-linux-64int -Dcc=/usr/bin/gcc -Dcpp=/usr/bin/cpp -DDEBUGGING=none -Doptimize=-Os -Dusemymalloc=n -Duseshrplib -Duselargefiles=yes -Duseposix=true -Dhint=recommended -Duseperlio=yes -Dccflags=-I/usr/local/cpanel/3rdparty/perl/514/include -L/usr/local/cpanel/3rdparty/perl/514/lib -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib -DAPPLLIB_EXP="/usr/local/cpanel" -Dcppflags=-I/usr/local/cpanel/3rdparty/perl/514/include -L/usr/local/cpanel/3rdparty/perl/514/lib -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib -Dldflags=-Wl,-rpath -Wl,/usr/local/cpanel/3rdparty/perl/514/lib -L/usr/local/cpanel/3rdparty/perl/514/lib -L/usr/local/cpanel/3rdparty/lib -Dprefix=/usr/local/cpanel/3rdparty/perl/514 -Dsiteprefix=/opt/cpanel/perl5/514 -Dsitebin=/opt/cpanel/perl5/514/bin -Dsitelib=/opt/cpanel/perl5/514/site_lib -Dusevendorprefix=true -Dvendorbin=/usr/local/cpanel/3rdparty/perl/514/bin -Dvendorprefix=/usr/local/cpanel/3rdparty/perl/514/lib/perl5 -Dvendorlib=/usr/local/cpanel/3rdparty/perl/514/lib/perl5/cpanel_lib -Dprivlib=/usr/local/cpanel/3rdparty/perl/514/lib/perl5/5.14.4 -Dman1dir=none -Dman3dir=none -Dscriptdir=/usr/local/cpanel/3rdparty/perl/514/bin -Dscriptdirexp=/usr/local/cpanel/3rdparty/perl/514/bin -Dsiteman1dir=none -Dsiteman3dir=none -Dinstallman1dir=none -Dversiononly=no -Dinstallusrbinperl=no -Dcf_by=cPanel -Dmyhostname=localhost -Dperladmin=root@localhost -Dcf_email=support@cpanel.net -Di_dbm=/usr/local/cpanel/3rdparty/include -Di_gdbm=/usr/local/cpanel/3rdparty/include -Di_ndbm=/usr/local/cpanel/3rdparty/include -Ud_dosuid -Uuserelocatableinc -Umad -Uusethreads -Uusemultiplicity -Uusesocks -Uuselongdouble -Ui_db -Aldflags=-L/usr/local/cpanel/3rdparty/perl/514/lib -L/usr/local/cpanel/3rdparty/lib -L/usr/lib -L/lib -lgdbm -Dlocincpth=/usr/local/cpanel/3rdparty/perl/514/include /usr/local/cpanel/3rdparty/include /usr/local/include -Duse64bitint -Uuse64bitall -Acflags=-fPIC -DPIC -m32 -I/usr/local/cpanel/3rdparty/perl/514/include -I/usr/local/cpanel/3rdparty/include -Dlibpth=/usr/local/cpanel/3rdparty/perl/514/lib /usr/local/cpanel/3rdparty/lib /usr/local/lib /lib /usr/lib ' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='/usr/bin/gcc', ccflags ='-I/usr/local/cpanel/3rdparty/perl/514/include -L/usr/local/cpanel/3rdparty/perl/514/lib -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib -DAPPLLIB_EXP="/usr/local/cpanel" -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-Os', cppflags='-I/usr/local/cpanel/3rdparty/perl/514/include -L/usr/local/cpanel/3rdparty/perl/514/lib -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib -I/usr/local/cpanel/3rdparty/perl/514/include -L/usr/local/cpanel/3rdparty/perl/514/lib -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib -DAPPLLIB_EXP="/usr/local/cpanel" -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.4.7 20120313 (Red Hat 4.4.7-3)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='/usr/bin/gcc', ldflags ='-Wl,-rpath -Wl,/usr/local/cpanel/3rdparty/perl/514/lib -L/usr/local/cpanel/3rdparty/perl/514/lib -L/usr/local/cpanel/3rdparty/lib -L/usr/local/cpanel/3rdparty/perl/514/lib -L/usr/local/cpanel/3rdparty/lib -L/usr/lib -L/lib -lgdbm -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.12.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.12' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/local/cpanel/3rdparty/perl/514/lib/perl5/5.14.4/i386-linux-64int/CORE' cccdlflags='-fPIC', lddlflags='-shared -Os -L/usr/local/cpanel/3rdparty/perl/514/lib -L/usr/local/cpanel/3rdparty/lib -L/usr/lib -L/lib -L/usr/local/lib -fstack-protector' Locally applied patches: cPanel patches cPanel INC path changes Disabled some unstable tests on a kvm build server Cherry pick of 49498ca from p5p (RT 113514) Remove improper use of each() in B::walksymtable (5cc8528c90) --- @INC for perl 5.14.4: /usr/local/cpanel /usr/local/cpanel /usr/local/cpanel/3rdparty/perl/514/lib/perl5/cpanel_lib/i386-linux-64int /usr/local/cpanel/3rdparty/perl/514/lib/perl5/cpanel_lib /usr/local/cpanel/3rdparty/perl/514/lib/perl5/5.14.4/i386-linux-64int /usr/local/cpanel/3rdparty/perl/514/lib/perl5/5.14.4 /opt/cpanel/perl5/514/site_lib/i386-linux-64int /opt/cpanel/perl5/514/site_lib . --- Environment for perl 5.14.4: HOME=/root LANG=en_US.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/root/.opt/bin:/usr/local/cpanel/3rdparty/perl/514/bin:/usr/local/cpanel/3rdparty/bin:/usr/local/cpanel/3rdparty/node/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin PERL5LIB=/usr/local/cpanel PERL_BADLANG (unset) SHELL=/bin/bash
From: Felipe Gasper <felipe [...] felipegasper.com>
To: perlbug-followup [...] perl.org
Date: Thu, 04 Sep 2014 14:43:43 -0500
Subject: Re: [perl #122703] perlbug AutoReply: chmod() doesn't populate a local()ed $!
Download (untitled) / with headers
text/plain 2.6k
chown() appears to have a similar problem. perl -MFile::Temp -e'my ($fh, $path) = File::Temp::tempfile(); close $fh; local ($!); my $ok = chown( 99, 99, $fh ); print "ok? [$ok] err? [$!/$^E]"' On 9/4/14 12:50 PM, perlbug-followup@perl.org wrote: Show quoted text
> Greetings, > > This message has been automatically generated in response to the > creation of a perl bug report regarding: > "chmod() doesn't populate a local()ed $!". > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [perl #122703]. > > You can view your ticket at > https://rt.perl.org/Ticket/Display.html?id=122703 > > Within the next 24 to 72 hours, your message will be posted to the Perl 5 Porters mailing list. Please be patient! > > Please include the string: > > [perl #122703] > > in the subject line of all future correspondence about this issue. To do so, > you may reply to this message (please delete unnecessary quotes and text.) > > Thank you, > perlbug-followup@perl.org > > ------------------------------------------------------------------------- > X-Antiabuse: This header was added to track abuse, please include it with any abuse report > X-Antiabuse: Primary Hostname - felipe.dev.cpanel.net > X-Antiabuse: Original Domain - perl.org > X-Antiabuse: Originator/Caller UID/GID - [0 0] / [47 12] > X-Antiabuse: Sender Address Domain - felipegasper.com > X-Get-Message-Sender-Via: felipe.dev.cpanel.net: sender_ident via received_protocol == local: root/only user confirmed/virtual account not confirmed > Message-ID: <5.14.4_13768_1409852466@felipe.dev.cpanel.net> > From: felipe@felipegasper.com > Return-Path: <felipe@felipegasper.com> > Delivered-To: rt-perl5@rt.perl.org > Delivered-To: perlbug@perl.org > X-Spam-Check-BY: la.mx.develooper.com > From felipe@felipegasper.com Thu Sep 04 17:50:06 2014 > X-Virus-Checked: Checked > Subject: chmod() doesn't populate a local()ed $! > To: perlbug@perl.org > X-Spam-Status: No, hits=-5.2 required=8.0 tests=BAYES_00,PERLBUG_CONF,SPF_SOFTFAIL,URIBL_BLOCKED > Date: Thu, 04 Sep 2014 12:43:13 -0500 > Received: (qmail 25993 invoked by uid 225); 4 Sep 2014 17:50:06 -0000 > Received: (qmail 25981 invoked by alias); 4 Sep 2014 17:50:01 -0000 > Received: from ng1.cptxoffice.net (HELO felipe.dev.cpanel.net) (208.74.121.102) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 04 Sep 2014 10:49:58 -0700 > Received: from root by felipe.dev.cpanel.net with local (Exim 4.82) (envelope-from <felipe@felipegasper.com>) id 1XPb3x-0003dN-6Z for perlbug@perl.org; Thu, 04 Sep 2014 12:43:13 -0500 > Reply-To: felipe@felipegasper.com > X-RT-Original-Encoding: ascii > content-type: text/plain; charset="utf-8" > X-RT-Interface: Email >
CC: "bugs-bitbucket [...] rt.perl.org" <bugs-bitbucket [...] rt.perl.org>
Subject: Re: [perl #122703] chmod() doesn't populate a local()ed $!
From: Leon Timmermans <fawaka [...] gmail.com>
To: Perl5 Porters <perl5-porters [...] perl.org>
Date: Thu, 4 Sep 2014 22:17:11 +0200
Download (untitled) / with headers
text/plain 641b
On Thu, Sep 4, 2014 at 7:50 PM, felipe@felipegasper.com <perlbug-followup@perl.org> wrote:
Show quoted text
perl -MFile::Temp -e'my ($fh, $path) = File::Temp::tempfile(); close $fh; local ($!); my $ok = chmod( 0111, $fh ); print "ok? [$ok] err? [$!/$^E]"'

The above breaks on every Perl version that I've tried: 5.14.4/Linux, 5.18.2/Mac, and 5.20.0/Mac.

If you take out the "local ($!);", then it populates $! as you'd expect.

The presence of «local $!» will prevent the previous value (from tempfile()) from being visible, but the real issue here is that you're trying to chmod a filehandle you've just closed. This is not a bug.

Leon
Subject: Re: [perl #122703] chmod() doesn't populate a local()ed $!
From: Felipe Gasper <felipe [...] felipegasper.com>
Date: Thu, 04 Sep 2014 15:50:04 -0500
To: perlbug-followup [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On 9/4/14 3:18 PM, Leon Timmermans via RT wrote: Show quoted text
> On Thu, Sep 4, 2014 at 7:50 PM, felipe@felipegasper.com < > perlbug-followup@perl.org> wrote: >
>> perl -MFile::Temp -e'my ($fh, $path) = File::Temp::tempfile(); close $fh; >> local ($!); my $ok = chmod( 0111, $fh ); print "ok? [$ok] err? [$!/$^E]"' >> >> The above breaks on every Perl version that I've tried: 5.14.4/Linux, >> 5.18.2/Mac, and 5.20.0/Mac. >> >> If you take out the "local ($!);", then it populates $! as you'd expect. >>
> > The presence of «local $!» will prevent the previous value (from > tempfile()) from being visible, but the real issue here is that you're > trying to chmod a filehandle you've just closed. This is not a bug.
Compare this to how print behaves: perl -MFile::Temp -e'my ($fh, $path) = File::Temp::tempfile(); close $fh; local ($!); my $ok = print {$fh} 123; print "ok? [$ok] err? [$!/$^E]"' ok? [] err? [Bad file descriptor/Bad file descriptor] ======== The documented behavior is that chown() and chmod() populate $! whenever there is an error. Perl is not implementing that behavior; by definition, this seems to be a bug. -FG
From: Curtis Jewell <perl [...] csjewell.fastmail.us>
Date: Thu, 04 Sep 2014 14:53:50 -0600
To: Leon Timmermans <fawaka [...] gmail.com>, Perl5 Porters <perl5-porters [...] perl.org>
CC: "bugs-bitbucket [...] rt.perl.org" <bugs-bitbucket [...] rt.perl.org>
Subject: Re: [perl #122703] chmod() doesn't populate a local()ed $!
Download (untitled) / with headers
text/plain 916b
He's trying to GENERATE an error in order to show that the local($!) makes the expected value of $! disappear. So yes, it is a bug. On Thu, Sep 4, 2014, at 14:17, Leon Timmermans wrote: Show quoted text
> On Thu, Sep 4, 2014 at 7:50 PM, felipe@felipegasper.com < > perlbug-followup@perl.org> wrote: >
> > > > > > The above breaks on every Perl version that I've tried: 5.14.4/Linux, > > 5.18.2/Mac, and 5.20.0/Mac. > > > > If you take out the "local ($!);", then it populates $! as you'd expect. > >
> > The presence of «local $!» will prevent the previous value (from > tempfile()) from being visible, but the real issue here is that you're > trying to chmod a filehandle you've just closed. This is not a bug. > > Leon
-- Curtis Jewell csjewell@cpan.org http://csjewell.dreamwidth.org/ perl@curtisjewell.name http://www.curtisjewell.name/ "Your random numbers are not that random" -- perl-5.10.1.tar.gz/util.c
Subject: Re: [perl #122703] chmod() doesn't populate a local()ed $!
CC: Father Chrysostomos via RT <perlbug-followup [...] perl.org>
Date: Thu, 4 Sep 2014 23:13:39 +0200
To: Felipe Gasper <felipe [...] felipegasper.com>
From: Leon Timmermans <fawaka [...] gmail.com>
Download (untitled) / with headers
text/plain 1000b
On Thu, Sep 4, 2014 at 10:50 PM, Felipe Gasper <felipe@felipegasper.com> wrote:
Show quoted text
Compare this to how print behaves:

perl -MFile::Temp -e'my ($fh, $path) = File::Temp::tempfile(); close $fh; local ($!); my $ok = print {$fh} 123; print "ok? [$ok] err? [$!/$^E]"'

ok? [] err? [Bad file descriptor/Bad file descriptor]
========

The documented behavior is that chown() and chmod() populate $! whenever there is an error. Perl is not implementing that behavior; by definition, this seems to be a bug.

Notice hor

$ perl -MFile::Temp -e'my ($fh, $path) = File::Temp::tempfile(); close $fh; $! = 0; my $ok = chmod( 0111, $fh ); print "ok? [$ok] err? [$!/$^E]"'

gives exactly the same result. The only conclusion that can be made here is that $! isn't being written to in the first place. This has nothing to do with localization.

Yes, it does not set $! if $fh is a closed filehandle (because it doesn't do any syscall). This is probably a bug, the attached patch fixes this.

Leon

Message body is not shown because sender requested not to inline it.

Date: Fri, 5 Sep 2014 11:16:23 +0200
To: perl5-porters [...] perl.org
From: Abigail <abigail [...] abigail.be>
Subject: Re: [perl #122703] chmod() doesn't populate a local()ed $!
Download (untitled) / with headers
text/plain 1.3k
On Thu, Sep 04, 2014 at 10:50:10AM -0700, felipe@felipegasper.com wrote: Show quoted text
> # New Ticket Created by felipe@felipegasper.com > # Please include the string: [perl #122703] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=122703 > > > > > This is a bug report for perl from felipe@felipegasper.com, > generated with the help of perlbug 1.39 running under perl 5.14.4. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > perl -MFile::Temp -e'my ($fh, $path) = File::Temp::tempfile(); close $fh; local ($!); my $ok = chmod( 0111, $fh ); print "ok? [$ok] err? [$!/$^E]"' > > The above breaks on every Perl version that I've tried: 5.14.4/Linux, 5.18.2/Mac, and 5.20.0/Mac. > > If you take out the "local ($!);", then it populates $! as you'd expect. >
It sets $! to "Inappropriate ioctl for device" on my box, which doesn't at all seem an error message I was expecting. In fact, that's what $! contains after File::Temp::tempfile: #!/usr/bin/perl use 5.010; use File::Temp; say "[$!]"; my ($fh, $path) = File::Temp::tempfile; say "[$!]"; __END__ [] [Inappropriate ioctl for device] Which further indicates what Leon was saying, the issue here is that chmod() doesn't populate $!. Abigail
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 353b
On Thu Sep 04 14:14:31 2014, LeonT wrote: Show quoted text
> Yes, it does not set $! if $fh is a closed filehandle (because it doesn't > do any syscall). This is probably a bug, the attached patch fixes this.
I've applied essentially this patch, but with some tests as 8334cae656b5c7fd6ff3536633897332d0ee089a. I didn't notice yours until after I'd written mine. Tony
Date: Wed, 22 Oct 2014 08:17:00 -0500
From: Felipe Gasper <felipe [...] felipegasper.com>
To: perlbug-followup [...] perl.org
Subject: Re: [perl #122703] [RESOLVED] chmod() doesn't populate a local()ed $!
Download (untitled) / with headers
text/plain 381b
Thank you! :) On 22 Oct 2014 12:39 AM, Tony Cook via RT wrote: Show quoted text
> According to our records, your request regarding > "chmod() doesn't populate a local()ed $!" > has been resolved. > > If you have any further questions or concerns, please respond to this message. > > For other topics, please create a new ticket. > > <URL: https://rt.perl.org/Ticket/Display.html?id=122703 > >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org