Web lists-archives.com

Re: EPERM on bind() ?




On Apr 23 14:17, E. Madison Bray wrote:
> Hello,
> 
> I have had some users of the Jupyter Notebook [1] on Cygwin report an
> crash on startup where, when the Notebook server tries to bind() to
> the port it will listen on (TCP 8888) the bind() fails and errno is
> set to EPERM, which is not an expected errno from bind().
> 
> Looking at the Cygwin sources, in net.cc I see that in
> set_winsock_errno, EPERM is returned by default if there is some WSA
> error for which there is no POSIX equivalent mapped.  Fine--EPERM is
> as good as any other fallback I suppose (?) in that it unambiguously
> indicates some unknown WSA error.

This code is as old as it can get.  The Winsock error fallback to EPERM
predates the Cygwin import into the public CVS repo on sourceware.org in
2000, and the pre-2000 ChangeLogs don't mention it.  There's a good
chance the mapping defaults to EPERM since 1996 when the first socket
support was added.

It's probably a good idea to change the default to EACCES, as for other,
non-WinSock errors.

> I'm just wondering if anyone has any idea what might cause such an
> error.

Nobody knows.  The problem is that we only know the POSIX fallback
but not the actual WSOCK error code.

If you can manage to run the server under strace to reproduce the issue,
then there will be an error message in strace along the lines of

"fhandler_socket*.cc:42 - winsock error 12345 -> errno 1"

The point here is to know what winsock error code that actually is.
What we can do then is to map it to a better POSIX error code or
maybe even see if there's a bug in Cygwin.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

Attachment: signature.asc
Description: PGP signature