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

Owner: Nobody
Requestors: zhouzhen1 [at] gmail.com
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: 5.23.4



From: Zhenyi Zhou <zhouzhen1 [...] gmail.com>
Date: Thu, 1 Oct 2015 11:59:22 +0800
To: perlbug [...] perl.org
Subject: POSIX::strerror() clears $!
Download (untitled) / with headers
text/plain 558b
I found that POSIX::strerror() clears $!. For example, 

perl -MPOSIX -e '$! = 29; strerror($!); print $!, "\n"';

prints nothing to terminal under Perl 5.22.0, 5.20.1, 5.14.2. However, it is able to print "Illegal seek" under 5.8.8 and 5.10.1. So it is likely to have broken since some time between 5.10 and 5.14 (, not tested 5.12 though).

And this is probably not an issue in POSIX itself. I looked at POSIX::strerror source, and further found that the issue demo can also be like below,  

perl -e '$! = 29; sub { local $! = $_[0]; }->($!); print "$!\n";'

Date: Thu, 1 Oct 2015 11:30:57 +0100
From: Dave Mitchell <davem [...] iabyn.com>
Subject: Re: [perl #126229] POSIX::strerror() clears $!
To: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Wed, Sep 30, 2015 at 08:59:32PM -0700, Zhenyi Zhou wrote: Show quoted text
> I found that POSIX::strerror() clears $!. For example, > > perl -MPOSIX -e '$! = 29; strerror($!); print $!, "\n"'; > > prints nothing to terminal under Perl 5.22.0, 5.20.1, 5.14.2. However, it > is able to print "Illegal seek" under 5.8.8 and 5.10.1. So it is likely to > have broken since some time between 5.10 and 5.14 (, not tested 5.12 > though). > > And this is probably not an issue in POSIX itself. I looked at > POSIX::strerror source, and further found that the issue demo can also be > like below, > > perl -e '$! = 29; sub { local $! = $_[0]; }->($!); print "$!\n";'
This can be reduced to $! = 29; { local $! = $! } print "[$!]\n"; # prints "[]" Its a messy interaction between local() and magic vars. I'm not sure it can be fixed. Of course the specific issue of strerror() is capable of being fixed, by avoiding the equivalent of local $! = $!. -- Music lesson: a symbiotic relationship whereby a pupil's embellishments concerning the amount of practice performed since the last lesson are rewarded with embellishments from the teacher concerning the pupil's progress over the corresponding period.
From: Dave Mitchell <davem [...] iabyn.com>
Date: Tue, 13 Oct 2015 12:24:30 +0100
To: perl5-porters [...] perl.org
Subject: Re: [perl #126229] POSIX::strerror() clears $!
Download (untitled) / with headers
text/plain 834b
On Thu, Oct 01, 2015 at 11:30:57AM +0100, Dave Mitchell wrote: Show quoted text
> This can be reduced to > > $! = 29; > { local $! = $! } > print "[$!]\n"; # prints "[]" > > Its a messy interaction between local() and magic vars. I'm not sure it can > be fixed.
Show quoted text
> Of course the specific issue of strerror() is capable of being > fixed, by avoiding the equivalent of local $! = $!.
And that's now fixed in bleadperl by commit 068e3fb. -- No man treats a motor car as foolishly as he treats another human being. When the car will not go, he does not attribute its annoying behaviour to sin, he does not say, You are a wicked motorcar, and I shall not give you any more petrol until you go. He attempts to find out what is wrong and set it right. -- Bertrand Russell, Has Religion Made Useful Contributions to Civilization?
Download (untitled) / with headers
text/plain 252b
Thank you for submitting this report. You have helped make Perl better. With the release of Perl 5.24.0 on May 9, 2016, this and 149 other issues have been resolved. Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0


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