Subject: 29.0.91; crash after creating graphical frames via emacsclient when compiled with cairo-xcb

From: Thiago Melo <[email-masked]>
Date: Fri, 19 May 2023 11:17:36 +0000

With emacs 29 compiled with cairo-xcb, after starting emacs-daemon,
repeatedly closing the last graphical frame and creating a new one via
emacsclient will eventually crash emacs (it takes a few seconds for
me). During the process, some frames might fail to be created (they
briefly appear and close themselves).

After the crash, I get the following error messages from the tty where
I started the daemon:

```
emacs: ../../../../src/cairo-xcb-screen.c:219: _get_screen_index:
Assertion `!"reached"' failed.

Fatal error 6: Aborted
```

Affects starting emacs with `emacs -Q --daemon`.

Issue happens since commit de614ec9 ("Use Cairo XCB surfaces when XCB
is available").

Compiling emacs with only cairo is enough to trigger the bug.
 'configure --without-all --with-x-toolkit=no --with-cairo'

Attached are a gdb session log with backtraces and system information.

Looking up the cairo-xcb error message above, I found a related
discussion at the cairo mailing list:

https://lists.cairographics.org/archives/cairo/2017-December/028491.html

Where someone had the same issue with a different software in a
similar scenario. One developer gives insight about the behavior and
suggests how to better manage cairo-xcb surfaces.

My workaround for now is patching emacs' configure.ac to disable cairo-xcb.