Subject: Re: bug#14333: 24.3.50; Emacs hangs when trying to exit

From: Eli Zaretskii <[email-masked]>
Date: Wed, 15 May 2013 20:18:21 +0300

> Date: Wed, 15 May 2013 18:47:26 +0200
> From: Dani Moncayo <[email-masked]>
> Cc: [email-masked]
> 
> Hi Eli, I chose your method "2" in the previous mail, and here are the results:

Thanks.

> * Emacs stack translation:
>     0x108ff4f is in term_winsock (w32.c:6008).

This is the main thread that is stuck here:

      if (pfn_WSACleanup () == 0 ||   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	  pfn_WSAGetLastError () == WSAENETDOWN)
	{
	  if (FreeLibrary (winsock_lib))
	  winsock_lib = NULL;
	  return TRUE;
	}

And it looks like it is stuck because the reader thread that listens
to some network connection is waiting for input:

>     0x1091a12 is in _sys_wait_accept (w32.c:6982).
>     0x105503d is in reader_thread (w32proc.c:1017).

here:

  if (rc != SOCKET_ERROR)
    {
      rc = WaitForSingleObject (hEv, INFINITE);  <<<<<<<<<<<<<<<<<<<<<<<<<
      pfn_WSAEventSelect (SOCK_HANDLE (fd), NULL, 0);
      if (rc == WAIT_OBJECT_0)
	cp->status = STATUS_READ_SUCCEEDED;
    }

Does this mean that if you start Emacs with "emacs -Q" and immediately
try to exit, Emacs shuts down cleanly?

Anyway, I will try to come up with some code that will unstuck this.