From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95996 invoked by alias); 23 Apr 2019 13:37:31 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 95727 invoked by uid 89); 23 Apr 2019 13:37:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=historical, wondering X-HELO: mail-it1-f194.google.com Received: from mail-it1-f194.google.com (HELO mail-it1-f194.google.com) (209.85.166.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Apr 2019 13:37:29 +0000 Received: by mail-it1-f194.google.com with SMTP id a190so117620ite.4 for ; Tue, 23 Apr 2019 06:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=ZOt1x+E2krL4W3WkAyvW7fejvz2Qy+UiAsPBJO5vAO8=; b=q/+vIlLiSxLFD6Vv8uHvRQ+F275mpn6Q6Loy/aYMc2CpqtdaZQX/gGIR4plNfK8Eqm qDbuNZDo9wkPYiatI56i/n+Ao/ZlPh8pVcroc6UK21dUOcc4J0XY+y31YDPMZx/czf/C MsdyfJNMEslCDSFzy5v7r7c78s79VOhZ80briwPCwhQxEZtGFHThQLcvdWw15LgrAaNl YwAwX9s7jWqYcw9rkX1Mdo+AUEB8GMJk3D0syuxfwhbZk0I2whnO3KmfUi3FNc9xXteZ CaG3FCycjrnIMQGHld3OI/buahYw7A6od67UvPteWOqukuNDOlmoDXENj9lufKpDNRSU k60g== MIME-Version: 1.0 References: <20190423124810.GD30041@calimero.vinschen.de> In-Reply-To: <20190423124810.GD30041@calimero.vinschen.de> From: "E. Madison Bray" Date: Tue, 23 Apr 2019 13:37:00 -0000 Message-ID: Subject: Re: EPERM on bind() ? To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00164.txt.bz2 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