public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "E. Madison Bray" <erik.m.bray@gmail.com>
To: cygwin@cygwin.com
Subject: Re: EPERM on bind() ?
Date: Tue, 23 Apr 2019 13:37:00 -0000	[thread overview]
Message-ID: <CAOTD34aAc0T1iNQBWjkkbva3q2e04Wu4gxNGrygbOjhQg70kUg@mail.gmail.com> (raw)
In-Reply-To: <20190423124810.GD30041@calimero.vinschen.de>

On Tue, Apr 23, 2019 at 2:48 PM Corinna Vinschen wrote:
>
> On Apr 23 14:28, E. Madison Bray wrote:
> > On Tue, Apr 23, 2019 at 2:17 PM 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.
> > >
> > > I'm just wondering if anyone has any idea what might cause such an
> > > error.  Some third-party firewall or BLODA?  I can't reproduce it
> > > myself.  Trying to bind to a port already in use correctly returns
> > > EADDRINUSE.
> > >
> > >
> > > [1] https://jupyter.org/
> >
> > Answering my own question after comparing the list on
> > https://docs.microsoft.com/en-us/windows/desktop/winsock/windows-sockets-error-codes-2
> > to Cygwin's wsock_errmap table this is a likely culprit:
> >
> > > WSAEACCES
> > > 10013
> > > Permission denied.An attempt was made to access a socket in a way forbidden by its access permissions.
> > > An example is using a broadcast address for sendto without broadcast permission being set using
> > > setsockopt(SO_BROADCAST).
> > > Another possible reason for the WSAEACCES error is that when the bind function is called (on Windows NT
> > > 4.0 with SP4 and later), another application, service, or kernel mode driver is bound to the same address
> > > with exclusive access. Such exclusive access is a new feature of Windows NT 4.0 with SP4 and later, and is
> > > implemented by using the SO_EXCLUSIVEADDRUSE option.
> >
> > This appears to be missing from the wsock_errmap table, but should
> > obviously map to EACCES.  I'll supply a patch.
>
> Good catch!  As I *just* wrote in my other reply, we should better
> default to EACCES.  It should be sufficient to change the default then.
> I'm looking forward to your patch submission.

Thanks Corinna for the historical background (I didn't even realize
how old that code was) and for the confirmation.  I'll do that.

On one hand EPERM sort of make sense just because it didn't map to
anything else, so it was useful in this case in identifying the
problem.  At the same time it's not a valid error for most any
socket-related function defined by POSIX that I can find, so EACCES
makes more sense.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2019-04-23 13:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23 12:17 E. Madison Bray
2019-04-23 12:28 ` E. Madison Bray
2019-04-23 12:48   ` Corinna Vinschen
2019-04-23 13:37     ` E. Madison Bray [this message]
2019-04-23 12:46 ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOTD34aAc0T1iNQBWjkkbva3q2e04Wu4gxNGrygbOjhQg70kUg@mail.gmail.com \
    --to=erik.m.bray@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).