develooper Front page | perl.perl5.porters | Postings from March 2015

Re: AnyEvent and Strawberry perl issue

Thread Next
From:
Marc Lehmann
Date:
March 13, 2015 07:33
Subject:
Re: AnyEvent and Strawberry perl issue
Message ID:
20150313073323.GD2454@schmorp.de
On Wed, Mar 11, 2015 at 05:35:17PM -0400, Laurent <laurent.aml@gmail.com> wrote:
> Apparently, in my setup of Strawberry Perl 5.20, syswrite reports
> POSIX::EWOULDBLOCK (140) instead of the WSAEWOULDBLOCK (10035) or EAGAIN.
> In particular, this makes the readline test fail:

The pain. It never ends.

Anyway, thanks for bringing this to my attention, I had no idea.

This is yet another idiotic bug in perl - the corresponding error code for
WSAEWOULDBLOCK would be EAGAIN (35), the winsock error codes are generally
shifted by 10000. This change breaks not only existing perl programs
(which makes it idiotic), but also most unix programs (which use EAGAIN,
as EWOULDBLOCK is virtually unused on unix for this).

(mingw gets it right, e.g.
http://lists.gnu.org/archive/html/bug-gnulib/2008-10/msg00068.html, so
again, I would have to recommend cygwin perl as this doesn't rely on the
broken unix emulation code in perl, and of course also gets this right).

I call it a bug because needlessly breaking compatibility with both
existing unix and windows code is just that - idiotic, and the only place
to fix it would be in strawberry perl (or perl). It's basically a change
*designed* to break compatibility with everything. And of course yet
another mindless change not tested or researched in any way.

However, since the perl5porters officially give a fuck about backwards
compatibility with existing code, chances of this getting fixed are small,
so I will have to slow down AnyEvent by checking for EWOULDBLOCK for just
this platform - that's what you get for letting perl6 people take over
perl5 to destroy that, too.

> Apparently, Perl 5.12 introduced the POSIX error codes for winsock (see
> http://perldoc.perl.org/5.12.0/perldelta.html). In particular, EWOULDBLOCK
> and EINPROGRESS are now supported on Windows.

The next problem here is that WSAEINPROGRESS doesn't correspond to POSIX
EINPROGRESS at all - they only have similar names and codes, but behaviour
is not compatible. For example, AnyEvent::Socket relies on the correct
error code (WSAEWOULDBLOCK instead of EINPROGRESS):

            (connect $state{fh}, $sockaddr)
            || ($! == Errno::EINPROGRESS # POSIX
                || $! == Errno::EWOULDBLOCK
                # WSAEINPROGRESS intentionally not checked - it means something else entirely
                || $! == AnyEvent::Util::WSAEINVAL # not convinced, but doesn't hurt
                || $! == AnyEvent::Util::WSAEWOULDBLOCK)

cygwin gets this right as well.

So this change probably breaks connections because the WSA error code is
mapped on the wrong POSIX code. I don't think this can be fixed nicely
either, it needs to be fixed in perl, where the incorrect mapping is.

So, summarily, the only fix is to make perl report the correct error
codes, and not substitute similarly-sounding-but-different-behaviour ones
from POSIX.

because reading the msdn documentation and the posix manpage is
obviously too much work for the perl maintainers.

Of course, things would be better if people who changed things actually
knew what they were doing or at least did some research instead of the
curent style of experimenting with things and letting CPAN fix around it
(as with the snake-poil security patches that don't fix security bugs but
break all the most commonly used modules on cpan...).

Reading the MSDN documentation on these error codes (and the posix
manpage) would have sufficed, but is obviously too much to ask for
compatibility-breaking change in perl.

Ugh.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp@schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About