Subject: | Bad arg length for Socket::sockaddr_family, length is 0, should be at least 2 |
Date: | Wed, 4 Sep 2019 09:33:28 -0700 |
To: | " bug-HTTP-Server-Simple [...] rt.cpan.org" <bug-HTTP-Server-Simple [...] rt.cpan.org> |
From: | Hermann Calabria <jason [...] ivouch.com> |
While using Perl Dancer under development mode, HTTP::Server::Simple crashes under perl 5.26.2. This happens very intermittently (as in rarely), but when it does, I get this:
Use of uninitialized value in subroutine entry at /home/jason/perl5/perlbrew/perls/perl-5.26.2/lib/site_perl/5.26.2/HTTP/Server/Simple.pm line 397.
Bad arg length for Socket::sockaddr_family, length is 0, should be at least 2 at /home/jason/perl5/perlbrew/perls/perl-5.26.2/lib/site_perl/5.26.2/HTTP/Server/Simple.pm line 397.
jason@bear:~/foo/bar$
I just restart my app and everything works well for awhile, until it crashes again. This is an annoyance more than anything, but should probably be fixed.
FYI … ./HTTP/Server/Simple.pm, near line 397:
sub _process_request {
my $self = shift;
# Create a callback closure that is invoked for each incoming request;
# the $self above is bound into the closure.
sub {
$self->stdio_handle(*STDIN) unless $self->stdio_handle;
# Default to unencoded, raw data out.
# if you're sending utf8 and latin1 data mixed, you may need to override this
binmode STDIN, ':raw';
binmode STDOUT, ':raw';
# The ternary operator below is to protect against a crash caused by IE
# Ported from Catalyst::Engine::HTTP (Originally by Jasper Krogh and Peter Edwards)
# ( http://dev.catalyst.perl.org/changeset/5195, 5221 )
my $remote_sockaddr = getpeername( $self->stdio_handle );
my $family = sockaddr_family($remote_sockaddr); ################# <====== LINE 397
my ( $iport, $iaddr ) = $remote_sockaddr
? ( ($family == AF_INET6) ? sockaddr_in6($remote_sockaddr)
: sockaddr_in($remote_sockaddr) )
: (undef,undef);
…