rjray / rpc-xml

A Perl implementation of the XML-RPC specification
https://metacpan.org/release/RPC-XML
24 stars 14 forks source link

Failed Server::url method (set) test when checking if a localhost regex matches #14

Closed kevinkjt2000 closed 3 years ago

kevinkjt2000 commented 6 years ago

I was trying to install the CPAN package as part of https://aur.archlinux.org/packages/perl-rpc-xml/ (which I need to compiler docker-git ultimately), but I ran into this error:

PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_load.t ..................... ok
t/10_data.t ..................... ok
t/11_base64_fh.t ................ ok
t/12_nil.t ...................... ok
t/13_no_deep_recursion.t ........ ok
t/14_datetime_iso8601.t ......... skipped: DateTime::Format::ISO8601 not available
t/15_serialize.t ................ ok
t/20_xml_parser.t ............... ok
t/21_xml_libxml.t ............... ok
t/25_parser_negative.t .......... ok
t/29_parserfactory.t ............ ok
t/30_procedure.t ................ ok
t/35_namespaces.t ............... ok
t/40_server.t ................... 16/91
#   Failed test 'RPC::XML::Server::url method (set)'
#   at t/40_server.t line 188.
#                   'http://[::1]:41259/'
#     doesn't match '(?^:http://(127[.]0[.]0[.]1|localhost|localhost[.]localdomain):41259)'
t/40_server.t ................... 35/91 Use of uninitialized value in subroutine entry at t/40_server.t line 276.
t/40_server.t ................... 41/91 Not an ARRAY reference at t/40_server.t line 333.
# Looks like your test exited with 255 just after 43.

I am not absolutely certain this is the correct repository to report this to, because perl package tests seem to fail often due to upstream changes from what little experience I have with CPAN.

rjray commented 6 years ago

(Dammit... that specific test (16) has caused me more headache than the whole remainder of the 40_server.t suite...)

Can you tell me your platform and Perl version that you're using? The initial test that fails (16) is just because I'm not IPv6-aware in the test. But the failures of 35 and 41 might be a bigger problem.

kevinkjt2000 commented 6 years ago

Arch Linux 4.14.6-1-ARCH x86_64 GNU/Linux

This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-thread-multi

Copyright 1987-2017, Larry Wall

rbtnx commented 6 years ago

There seems to be a problem with the ipv6 loopback notation in /etc/hosts. When commented out the error does not occur (tested on my arch machine)

kevinkjt2000 commented 6 years ago

What about checking if either localhost style regex matches or if http://search.cpan.org/~manu/Net-IP-1.25/IP.pm#ip_is_ipv4 or http://search.cpan.org/~manu/Net-IP-1.25/IP.pm#ip_is_ipv6 is true?

I suppose that much more than just validating string addresses is needed for IPv6 compatibility.

rjray commented 6 years ago

(Sorry, been on vacation and away from email)

Those are good suggestions. When I get some spare cycles I'll look at them.

renyuneyun commented 6 years ago

I hand-crafted a quick patch by adding the ipv6 loopback address to the @allhosts array but that doesn't solve the whole problem.

All I did is to change line 175 to

my @allhosts = ($local_ip, '\[::1\]', $localhostinfo[0], split q{ } => $localhostinfo[1]);

This reduces the first part of the error

t/40_server.t ................... 16/91
#   Failed test 'RPC::XML::Server::url method (set)'
#   at t/40_server.t line 188.
#                   'http://[::1]:41259/'
#     doesn't match '(?^:http://(127[.]0[.]0[.]1|localhost|localhost[.]localdomain):41259)'

but has nothing to do with the other parts. It seems that the other parts of (at least) this file doesn't work correctly for ipv6 addresses (at least [::1]).

In the meantime, I also tried deleting the ipv6 line from /etc/hosts and this "solved" the problem.

Ongy commented 6 years ago

@renyuneyun looking at your output, you didn't add it correctly. The doesn't match string there doesn't contain the ::1 And I don't think it needs the [] either, it should be a literal to compare to (like localhost) I just ran into this today, disabling IPv6 on the lo device worked well, but it's not exactly optimal either

daveloyall commented 4 years ago

I don't speak Perl, but I encountered this bug today and found this CPAN bug report which is about the same issue and has a patch attached. https://rt.cpan.org/Public/Bug/Display.html?id=120472

rjray commented 3 years ago

I have addressed this in the most-recent release (0.81), uploaded to CPAN this evening.