Subject: bug#26458: 25.1; abort on X close window

From: Eli Zaretskii <[email-masked]>
Date: Wed, 12 Apr 2017 09:14:40 +0300

> From: Kevin Ryde <[email-masked]>
> Date: Wed, 12 Apr 2017 15:02:52 +1000
> 
> Under X and motif mwm window manager, closing emacs using the window
> manager does not save modified buffers, and sometimes aborts.  Eg.
> 
>     emacs -Q /tmp/x
>     Ret                   # so modified
>     mwm Alt-f4 "close"
>     =>
>     Connection lost to X server ':0.0'
>     file /tmp/x not saved   
> 
> where I hoped to get the usual query save before exit as by C-x C-c or
> menu File/Quit.
> 
> (Generally X clients can treat WM_DELETE_WINDOW message the same as
> other user keyboard or menu input asking for an orderly shutdown -- so
> interaction and display continuing as normal for however long.)

Emacs does do this, so the problem is not on that high level, the
problem is in the details.  I'm guessing that Emacs does attempt to
display the dialog you wanted to see, but it cannot do that without an
X connection.

> Sometimes WM_DELETE_WINDOW can make emacs abort, depending what the kill
> hooks do.  For example foo.el containing
> 
>     (add-hook 'kill-emacs-hook
>               (lambda ()
>                 (sit-for 5)))
> 
> then
> 
>     emacs -Q -l foo.el
>     mwm Alt-f4 "close"
>     =>
>     Connection lost to X server ':0.0'
>     Fatal error 6: Aborted
>     Backtrace:
>     emacs[0x8144f1c]
>     ...
>     /usr/lib/i386-linux-gnu/libX11.so.6(_XIOError+0x5d)[0xb7345c2d]
>     /usr/lib/i386-linux-gnu/libX11.so.6(_XEventsQueued+0x96)[0xb7343266]
>     /usr/lib/i386-linux-gnu/libX11.so.6(XPending+0x62)[0xb7334752]
>     ...

Please show a full backtrace under a debugger, so we see where it
aborts.  It is best to run Emacs with -xrm "emacs.synchronous: true"
on the command line for this experiment, so that X errors are noted
right where they happen.

Thanks.