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

From: Dani Moncayo <[email-masked]>
Date: Thu, 21 Nov 2013 18:10:30 +0100

>> Can you try adding this line:
>>
>>     Sleep (1000);
>
> Actually, let's try with something that should be abundantly enough:
>
>         Sleep (20000);
>
> (that's 20-sec wait).  It will let Emacs wait for 20 sec during exit,
> but the question is, does it solve the hang?  If it does, I will come
> up with a more clever wait procedure.

I patched my emacs that way, and I've used this for two days, but
sadly I've just got another hung session:

(gdb) thread apply all bt

Thread 5 (Thread 4388.0x1ff8):
#0  0x778d000d in ntdll!DbgBreakPoint () from C:\Windows\SysWOW64\ntdll.dll
#1  0x7795f8ee in ntdll!DbgUiRemoteBreakin () from C:\Windows\SysWOW64\ntdll.dll
#2  0x1d9bdd74 in ?? ()
#3  0x00000000 in ?? ()

Thread 4 (Thread 4388.0xcd4):
#0  0x778df8d1 in ntdll!ZwWaitForSingleObject () from
C:\Windows\SysWOW64\ntdll.dll
#1  0x778df8d1 in ntdll!ZwWaitForSingleObject () from
C:\Windows\SysWOW64\ntdll.dll
#2  0x778fb4b4 in ntdll!RtlIntegerToUnicodeString () from
C:\Windows\SysWOW64\ntdll.dll
#3  0x778fb398 in ntdll!RtlIntegerToUnicodeString () from
C:\Windows\SysWOW64\ntdll.dll
#4  0x7791650d in ntdll!LdrShutdownThread () from C:\Windows\SysWOW64\ntdll.dll
#5  0x779c20c0 in ntdll!NlsAnsiCodePage () from C:\Windows\SysWOW64\ntdll.dll
#6  0x1f56dd84 in ?? ()
#7  0x00000000 in ?? ()

Thread 3 (Thread 4388.0x154c):
#0  0x764e78d7 in USER32!DispatchMessageW () from C:\Windows\syswow64\user32.dll
#1  0x011e1de5 in w32_msg_pump (msg_buf=0x6933ff28) at
../../repo/src/w32fns.c:2436
#2  0x011e2023 in w32_msg_worker@4 (arg=0x0) at ../../repo/src/w32fns.c:2662
#3  0x7733336a in KERNEL32!BaseThreadInitThunk () from
C:\Windows\syswow64\kernel32.dll
#4  0x778fbf32 in ntdll!RtlInitializeExceptionChain ()
   from C:\Windows\SysWOW64\ntdll.dll
#5  0x778fbf05 in ntdll!RtlInitializeExceptionChain ()
   from C:\Windows\SysWOW64\ntdll.dll
#6  0x00000000 in ?? ()

Thread 2 (Thread 4388.0x1e44):
#0  0x778e015d in ntdll!ZwWaitForMultipleObjects () from
C:\Windows\SysWOW64\ntdll.dll
#1  0x778e015d in ntdll!ZwWaitForMultipleObjects () from
C:\Windows\SysWOW64\ntdll.dll
#2  0x778fc6c5 in ntdll!RtlRegisterThreadWithCsrss () from
C:\Windows\SysWOW64\ntdll.dll
#3  0x7733336a in KERNEL32!BaseThreadInitThunk () from
C:\Windows\syswow64\kernel32.dll
#4  0x778fbf32 in ntdll!RtlInitializeExceptionChain ()
   from C:\Windows\SysWOW64\ntdll.dll
#5  0x778fbf05 in ntdll!RtlInitializeExceptionChain ()
   from C:\Windows\SysWOW64\ntdll.dll
#6  0x00000000 in ?? ()

Thread 1 (Thread 4388.0x16b8):
#0  0x778df8d1 in ntdll!ZwWaitForSingleObject () from
C:\Windows\SysWOW64\ntdll.dll
#1  0x778df8d1 in ntdll!ZwWaitForSingleObject () from
C:\Windows\SysWOW64\ntdll.dll
#2  0x778fb4b4 in ntdll!RtlIntegerToUnicodeString () from
C:\Windows\SysWOW64\ntdll.dll
#3  0x778fb398 in ntdll!RtlIntegerToUnicodeString () from
C:\Windows\SysWOW64\ntdll.dll
#4  0x77903ab8 in ntdll!LdrUnloadDll () from C:\Windows\SysWOW64\ntdll.dll
#5  0x779c20c0 in ntdll!NlsAnsiCodePage () from C:\Windows\SysWOW64\ntdll.dll
#6  0x77f3cf20 in ?? ()
#7  0x698c0878 in ?? ()
#8  0x767e2d1f in KERNELBASE!FreeLibrary () from
C:\Windows\syswow64\KernelBase.dll
#9  0x6fe4c1ad in NSPStartup () from C:\Windows\System32\mswsock.dll
#10 0x6fe4c207 in NSPStartup () from C:\Windows\System32\mswsock.dll
#11 0x771eaf4c in WahEnumerateHandleContexts () from
C:\Windows\syswow64\ws2_32.dll
#12 0x771eae54 in WahEnumerateHandleContexts () from
C:\Windows\syswow64\ws2_32.dll
#13 0x771e659e in WSACloseEvent () from C:\Windows\syswow64\ws2_32.dll
#14 0x00000000 in ?? ()

-- 
Dani Moncayo