Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

t/04_client_tests.t fails with perl 5.21.7 #18

Closed
eserte opened this issue Dec 25, 2014 · 6 comments
Closed

t/04_client_tests.t fails with perl 5.21.7 #18

eserte opened this issue Dec 25, 2014 · 6 comments

Comments

@eserte
Copy link

eserte commented Dec 25, 2014

See http://matrix.cpantesters.org/?dist=Riak-Light for a pass/fail overview and http://www.cpantesters.org/cpan/report/d64550d2-8a73-11e4-8b82-bb06e1bfc7aa for a sample fail report. I don't see a simple reason why it's failing. If you think this is a perl regression, then please report at perl5-porters.

@peczenyj
Copy link
Member

Hello,

I am reading the code and seems the problem is related to the global
variable $! or some cast to string. this is "ugly" but in this case, make
sense

I will try to reproduce with perlbrew, then check if there is some
workaround to fix the test ( maybe my code must be more consistent, I saw
other failures like this :
http://www.cpantesters.org/cpan/report/33eda834-8a73-11e4-9774-8304e1bfc7aa
and seems i should use strerror in many places - to be careful with
locale/language settings ).

Then I will try to write a small proof of concept and sent to the
perl5-porters to see if it is a bug or not.

Thanks

Tiago

On Thu, Dec 25, 2014 at 6:28 PM, Slaven Rezić [email protected]
wrote:

See http://matrix.cpantesters.org/?dist=Riak-Light for a pass/fail
overview and
http://www.cpantesters.org/cpan/report/d64550d2-8a73-11e4-8b82-bb06e1bfc7aa
for a sample fail report. I don't see a simple reason why it's failing. If
you think this is a perl regression, then please report at perl5-porters.


Reply to this email directly or view it on GitHub
#18.

Tiago B. Peczenyj
Linux User #405772

http://about.me/peczenyj

@peczenyj
Copy link
Member

Hello

I write this minimal test and check under 5.12.2 and 5.21.7

package Subject;
use Data::Dumper;

sub new {
  bless {};
}

sub ping {
  die "lol ($!)"
}

package main;

use strict;
use warnings;
use Data::Dumper;
use Test::More;
use Test::Exception;
use POSIX qw(ETIMEDOUT strerror);


        my $client = Subject->new();

        $! = ETIMEDOUT;
        #debug
        diag Dumper { ETIMEDOUT => ETIMEDOUT, error => $! };

        my $errmsg = strerror(ETIMEDOUT);
        throws_ok { $client->ping() } qr/lol \($errmsg\)/,
          "should die";

done_testing;

results:

$ perlbrew switch 5.12.2
$ prove -lv b.t
b.t .. 
ok 1 - should die
1..1
# $VAR1 = {
#           'error' => 'Operation timed out',
#           'ETIMEDOUT' => 60
#         };
ok
All tests successful.
Files=1, Tests=1,  0 wallclock secs ( 0.03 usr  0.00 sys +  0.04 cusr  0.01 csys =  0.08 CPU)
Result: PASS
$ perlbrew switch 5.21.7
$ prove -lv b.t
b.t .. 
not ok 1 - should die
1..1
# $VAR1 = {
#           'ETIMEDOUT' => 60,
#           'error' => 'Operation timed out'
#         };

#   Failed test 'should die'
#   at b.t line 29.
# expecting: Regexp ((?^:lol \(Operation timed out\)))
# found: lol () at b.t line 9.
# Looks like you failed 1 test of 1.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests 

Test Summary Report
-------------------
b.t (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=1,  0 wallclock secs ( 0.03 usr  0.01 sys +  0.08 cusr  0.01 csys =  0.13 CPU)
Result: FAIL

IF we move the debug message to the line below POSIX::strerror, we discover the $! variable has been erased.

And yet, the strerror has been changed between 5.21.6 and 5.21.7

Thanks for the report.

@eserte
Copy link
Author

eserte commented Dec 26, 2014

An even smaller test case:

$ perl5.21.6 -MErrno=ETIMEDOUT -MPOSIX=strerror -e '$! = ETIMEDOUT; strerror(ETIMEDOUT); warn $!'         
Connection timed out at -e line 1.
$ perl5.21.7 -MErrno=ETIMEDOUT -MPOSIX=strerror -e '$! = ETIMEDOUT; strerror(ETIMEDOUT); warn $!'
Warning: something's wrong at -e line 1.

And I see the problem in POSIX.pm: the strerror() implementation loads first locale.pm, which clobbers $!, and then does a local $!. Probably worth a bug report at perl5-porters.

A simple workaround would be to just "require locale" first.

@peczenyj
Copy link
Member

I open one ticket

Thanks

https://rt.perl.org/Ticket/Display.html?id=123503
Em 26/12/2014 11:34, "Slaven Rezić" [email protected] escreveu:

An even smaller test case:

$ perl5.21.6 -MErrno=ETIMEDOUT -MPOSIX=strerror -e '$! = ETIMEDOUT; strerror(ETIMEDOUT); warn $!'
Connection timed out at -e line 1.
$ perl5.21.7 -MErrno=ETIMEDOUT -MPOSIX=strerror -e '$! = ETIMEDOUT; strerror(ETIMEDOUT); warn $!'
Warning: something's wrong at -e line 1.

And I see the problem in POSIX.pm: the strerror() implementation loads
first locale.pm, which clobbers $!, and then does a local $!. Probably
worth a bug report at perl5-porters.

A simple workaround would be to just "require locale" first.


Reply to this email directly or view it on GitHub
#18 (comment).

@peczenyj
Copy link
Member

this error is related to a bugus implementation of POSIX::strerror on this particular version. I will close this ticket and follot the 123503 ticket on perl.org

@peczenyj
Copy link
Member

peczenyj commented Jan 7, 2015

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

No branches or pull requests

2 participants