Subject: Re: bug#63589: [PATCH] 29.0.91; crash after creating graphical frames via emacsclient when compiled with cairo-xcb

From: Thiago Melo <[email-masked]>
Date: Wed, 24 May 2023 05:15:46 +0000

> > Which is why I asked whether x-delete-terminal etc. could call a
> > function that is different from what we call when we exit.
>
> Why is what Emacs does upon exiting relevant here?
> The problem occurs when a display connection is closed while Emacs
> wants to stay running.  Cairo keeps a pointer to the xcb connection,
> and if by some chance a pointer with the same value is returned the
> next time a display connection is opened, it loses.

Regardless of what Emacs does at exit, you were right to point out
about calling, eg, the elisp function `delete-terminal', Po Lu. It
ends up always calling XCloseDisplay and, in fact, the last patch
doesn't cover it. I've tested it, and it even triggers the bug with
Lucid and GTK builds.

Here's an updated script to trigger the bug in all these cases:

#+begin_src bash
# repeatedly create graphical frames and close them all
for k in $(seq 10); do
    emacsclient -c -n -a /bin/false &&
        sleep 1 &&
        emacsclient -e "(delete-terminal)"
done
#+end_src