develooper Front page | perl.perl5.porters | Postings from October 2014

Re: [MSWin32] I need help with RT#98976

Thread Previous
Craig A. Berry
October 3, 2014 19:12
Re: [MSWin32] I need help with RT#98976
Message ID:
On Thu, Oct 2, 2014 at 7:27 PM, bulk88 <> wrote:
> Craig A. Berry wrote:
>> I've now built blead on Windows 7 and commented out the skip; the
>> 22timeout.t test never failed in a couple dozen runs on a pretty fast
>> i7 laptop.  I believe the failing smokes were on older versions of
>> Windows, and/or possibly on slower VMs, which may or may not be
>> relevant.  So I don't have anything to debug on Windows.  There aren't
>> that many places in the relevant code, though, where a file descriptor
>> is passed to a syscall, so that select is still a prime suspect.
>> Do note that the blocking() implementation, which as far as I can tell
>> is inherited from IO::Socket, is different on Windows and VMS from
>> everything else.  Again, may or may not be relevant, but it's
>> different from systems where things are working.
> As I said on the CPAN ticket (#I dont have off hand) over this issue, you
> need 100% CPU for it to fail on windows. Preferably Perl building or smoking
> in a tab in the background. I have 2 cores, Perl building in another console
> in background will make it fail 90% of the time for me, vs 5% of the time at
> idle.

It's 100% reproducible on an ancient, slow Windows XP box, though it
is a bit finicky about where breakpoints are set; it's easy to make it
succeed by stopping too long in the wrong place.  What I've been able
to narrow down is that the following happens inside
IO::Socket::IP::connect (and immediately after returning from it):

1.) The first call to CORE::connect sets EWOULDBLOCK, which is normal.
2.) The select fires immediately even with a lengthy timeout, which
could be normal if the connection is really complete.
3.) The second call to CORE::connect fails with EINVAL, which is quite
odd considering it's the same parameters passed to it in the first
4.) Some anonymous function deep in the bowels of Test::Builder
rewrites $! from EINVAL to EBADF.  That looks like a different bug.

#3 seems to be where things have gone badly wrong.  The standard says
EINVAL on connect means, "The address_len argument is not a valid
length for the address family; or invalid address family in the
sockaddr structure."  Which makes it sound like the sockaddr struct
got mangled somehow, but I have no idea how.

Debugging session details below:

C:\perlgit\cpan\IO-Socket-IP>..\..\perl -d -I..\..\lib t\22timeout.t

Loading DB routines from version 1.46
Editor support available.

Enter h or 'h h' for help, or 'perldoc perldebug' for more help.

main::(t\22timeout.t:11):       my $server = IO::Socket::IP->new(
main::(t\22timeout.t:12):          Listen    => 1,
main::(t\22timeout.t:13):          LocalHost => "",
main::(t\22timeout.t:14):          LocalPort => 0,
main::(t\22timeout.t:15):       ) or die "Cannot listen on PF_INET - $!";
  DB<1> n
main::(t\22timeout.t:17):       my $client = IO::Socket::IP->new(
main::(t\22timeout.t:18):          PeerHost => $server->sockhost,
main::(t\22timeout.t:19):          PeerPort => $server->sockport,
main::(t\22timeout.t:20):          Timeout  => 0.1,
main::(t\22timeout.t:21):       ) or die "Cannot connect on PF_INET - $!";
  DB<1> b IO::Socket::IP::connect
  DB<2> c
652:       my $self = shift;
  DB<2> b 698
  DB<3> c
698:          $! = $err, return undef if $err;
  DB<3> x $!, $err
0  'Invalid argument'
1  22
  DB<4> s
625:             if( $! == EINPROGRESS or HAVE_MSWIN32 && $! ==
Errno::EWOULDBLOCK() ) {
  DB<4> b 647
  DB<5> c
647:       return undef;
  DB<5> x $!, $@
0  'Invalid argument'
1  'Invalid argument'
  DB<6> w $!
  DB<7> c
Cannot connect on PF_INET - Bad file descriptor at t\22timeout.t line 17.
 at t\22timeout.t line 17.
Watchpoint 0:   $! changed:
    old value:  'Invalid argument'
    new value:  'Bad file descriptor'
2587:       $Test->_ending if defined $Test;


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About