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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 12 Sep 2014 11:11:33 +0300

> Date: Fri, 12 Sep 2014 08:14:40 +0200
> From: Dani Moncayo <[email-masked]>
> Cc: "[email-masked]" <[email-masked]>
> 
> KERNELBASE.dll!GetModuleFileNameW+0x3bd
> KERNELBASE.dll!GetModuleHandleW+0x29
> KERNELBASE.dll!GetModuleHandleA+0x34
> emacs.exe+0x135a     ?? at cygming-crtbegin.c:0
> emacs.exe+0xf6827    shut_down_emacs at emacs.c:1991
> emacs.exe+0xf2238    SUBRP at lisp.h:2471
> emacs.exe+0xf0add    XSUBR at lisp.h:914
> emacs.exe+0x185bcf   Ffuncall at eval.c:2815
> emacs.exe+0x1c685c   exec_byte_code at bytecode.c:916

This looks like an assertion violation (that somehow leads to a
deadlock).  The call to Ffuncall at eval.c:2815 should have called
Fkill_emacs, after extracting its function pointer:

  2814                case 1:
  2815                  val = (XSUBR (fun)->function.a1 (internal_args[0]));
  2816                  break;

Instead, it seems to hit the assertion violation inside XSUBR.

Could you next time attach GDB to a running Emacs (before it hangs),
or start Emacs under GDB to begin with, put a breakpoint in 'die' and
in 'Fkill_emacs', and see what happens when you exit?  If the
breakpoint inside 'Fkill_emacs' breaks, just type the "continue"
command; Emacs will probably exit normally.  But if the breakpoint in
'die' breaks, please see what kind of object do you have in 'fun', the
value that is passed to XSUBR on line 2815 above.

Do you have some hooks that are run via kill-emacs-query-functions?
If so, what are they?

Also, is it possible that you are exiting Emacs from a client frame,
i.e. a frame that was created by emacsclient?