GNU bug report logs - #49496
28.0.50; process-tests/fd-setsize-no-crash/make-network-process hangs on Cygwin

Previous Next

Package: emacs;

Reported by: Ken Brown <kbrown <at> cornell.edu>

Date: Fri, 9 Jul 2021 18:08:02 UTC

Severity: normal

Found in version 28.0.50

Done: Ken Brown <kbrown <at> cornell.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49496 in the body.
You can then email your comments to 49496 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#49496; Package emacs. (Fri, 09 Jul 2021 18:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ken Brown <kbrown <at> cornell.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 09 Jul 2021 18:08:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ken Brown <kbrown <at> cornell.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; process-tests/fd-setsize-no-crash/make-network-process hangs
 on Cygwin
Date: Fri, 9 Jul 2021 14:01:33 -0400
The hang can actually be triggered by evaluating the following, extracted from 
the test in the subject:

(setq socket-name "/tmp/socktest/socket")
(delete-file socket-name)
(make-network-process :name "server"
                      :server 10
                      :buffer nil
                      :service socket-name
                      :family 'local
                      :coding 'no-conversion
                      :noquery t)
(make-network-process :name "client"
		      :service socket-name
		      :family 'local
		      :coding 'no-conversion
		      :noquery t)

The reason for the hang is that Cygwin does a blocking handshake in 
accept/connect to exchange credentials.  This can hang in certain situations in 
which connect is called before a listening socket is ready to accept connections.

It is possible to work around this problem by disabling the credential exchange 
as in the following patch:

diff --git a/src/process.c b/src/process.c
index b8c3e4ecfb..01548c8ab5 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3355,6 +3355,12 @@ connect_network_socket (Lisp_Object proc, Lisp_Object 
addrinfos,
 	      xerrno = EMFILE;
 	      continue;
 	    }
+#ifdef CYGWIN
+	  /* Avoid possible hang in connect/accept.  */
+	  if (family == AF_LOCAL && p->socktype == SOCK_STREAM
+	      && setsockopt (s, SOL_SOCKET, SO_PEERCRED, 0, 0) < 0)
+	    report_file_error ("Cannot disable credential exchange", Qnil);
+#endif
 	}
        if (p->is_non_blocking_client && ! (SOCK_NONBLOCK && socket_to_use < 0))

But this seems too drastic just to fix a potential problem that doesn't seem to 
occur in practice, but only in the contrived situation of 
process-tests/fd-setsize-no-crash/make-network-process.  So my preference is to 
simply skip that test on Cygwin.

OK?

In GNU Emacs 28.0.50 (build 9, x86_64-pc-cygwin, GTK+ Version 3.22.28, cairo 
version 1.17.4)
 of 2021-07-09 built on moufang2
Repository revision: 68276f6d30bbdc09cc26fb49d7f0c3aa4bce35f2
Repository branch: master
Windowing system distributor 'The Cygwin/X Project', version 11.0.12011000
Configured using:
 'configure 'CFLAGS=-g -O0''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBXML2 M17N_FLT MODULES NOTIFY GFILENOTIFY PDUMPER PNG
RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49496; Package emacs. (Fri, 09 Jul 2021 18:20:02 GMT) Full text and rfc822 format available.

Message #8 received at 49496 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ken Brown <kbrown <at> cornell.edu>
Cc: 49496 <at> debbugs.gnu.org
Subject: Re: bug#49496: 28.0.50;
 process-tests/fd-setsize-no-crash/make-network-process hangs on Cygwin
Date: Fri, 09 Jul 2021 21:18:43 +0300
> From: Ken Brown <kbrown <at> cornell.edu>
> Date: Fri, 9 Jul 2021 14:01:33 -0400
> 
> It is possible to work around this problem by disabling the credential exchange 
> as in the following patch:
> 
> diff --git a/src/process.c b/src/process.c
> index b8c3e4ecfb..01548c8ab5 100644
> --- a/src/process.c
> +++ b/src/process.c
> @@ -3355,6 +3355,12 @@ connect_network_socket (Lisp_Object proc, Lisp_Object 
> addrinfos,
>   	      xerrno = EMFILE;
>   	      continue;
>   	    }
> +#ifdef CYGWIN
> +	  /* Avoid possible hang in connect/accept.  */
> +	  if (family == AF_LOCAL && p->socktype == SOCK_STREAM
> +	      && setsockopt (s, SOL_SOCKET, SO_PEERCRED, 0, 0) < 0)
> +	    report_file_error ("Cannot disable credential exchange", Qnil);
> +#endif
>   	}
>          if (p->is_non_blocking_client && ! (SOCK_NONBLOCK && socket_to_use < 0))
> 
> But this seems too drastic just to fix a potential problem that doesn't seem to 
> occur in practice, but only in the contrived situation of 
> process-tests/fd-setsize-no-crash/make-network-process.  So my preference is to 
> simply skip that test on Cygwin.
> 
> OK?

Yes, OK.  But please explain there in a comment why we skip that, with
a reference to this bug.

(FWIW, I consider the process-tests suite to be not useful enough, in
that it many times tests behavior that is only guaranteed to happen on
GNU/Linux, and is not really required, nor should be expected, in
portable Lisp programs.  So it doesn't surprise me that some of the
tests fail on some systems.)




Reply sent to Ken Brown <kbrown <at> cornell.edu>:
You have taken responsibility. (Fri, 09 Jul 2021 20:44:02 GMT) Full text and rfc822 format available.

Notification sent to Ken Brown <kbrown <at> cornell.edu>:
bug acknowledged by developer. (Fri, 09 Jul 2021 20:44:02 GMT) Full text and rfc822 format available.

Message #13 received at 49496-done <at> debbugs.gnu.org (full text, mbox):

From: Ken Brown <kbrown <at> cornell.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 49496-done <at> debbugs.gnu.org
Subject: Re: bug#49496: 28.0.50;
 process-tests/fd-setsize-no-crash/make-network-process hangs on Cygwin
Date: Fri, 9 Jul 2021 16:42:36 -0400
On 7/9/2021 2:18 PM, Eli Zaretskii wrote:
> Yes, OK.  But please explain there in a comment why we skip that, with
> a reference to this bug.

Done.  Closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 07 Aug 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 256 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.