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

POSIX::strerror() clears $! #14951

Closed
p5pRT opened this issue Oct 1, 2015 · 7 comments
Closed

POSIX::strerror() clears $! #14951

p5pRT opened this issue Oct 1, 2015 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 1, 2015

Migrated from rt.perl.org#126229 (status was 'resolved')

Searchable as RT126229$

@p5pRT
Copy link
Author

p5pRT commented Oct 1, 2015

From zhouzhen1@gmail.com

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";'

@p5pRT
Copy link
Author

p5pRT commented Oct 1, 2015

From @iabyn

On Wed, Sep 30, 2015 at 08​:59​:32PM -0700, Zhenyi Zhou wrote​:

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.

@p5pRT
Copy link
Author

p5pRT commented Oct 1, 2015

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2015

From @iabyn

On Thu, Oct 01, 2015 at 11​:30​:57AM +0100, Dave Mitchell wrote​:

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 $! = $!.

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?

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2015

@iabyn - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 13, 2016

From @khwilliamson

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

@p5pRT
Copy link
Author

p5pRT commented May 13, 2016

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant