Subject: bug#56967: 29.0.50; Frequent crashes under Wayland

From: Po Lu <[email-masked]>
Date: Fri, 05 Aug 2022 08:50:39 +0800

Bjoern Bidar <[email-masked]> writes:

>> Eli Zaretskii <[email-masked]> writes:
>
>> > Then please run Emacs under a debugger, or attach a debugger to it
>> > after you start it, and place a breakpoint in the function
>> > Fkill_emacs.  When that breakpoint breaks, produce a backtrace (with
>> > the "thread apply all bt" command in GDB) and post that backtrace
>> > here.
>> 
>> Please also place a breakpoint on _exit -- GDK always calls that with
>> the exit code 1 that when a display connection is abruptly lost, in
>> which case Fkill_emacs has no chance to run.
>> 
>> Thanks in advance.
>
> Started emacs via systemd as and set both break points as asked.
>
> There you go:
>
>
> Thread 1 "emacs" hit Breakpoint 2, __GI__exit (status=status@entry=1) at ../
> sysdeps/unix/sysv/linux/_exit.c:27
> 27      {
> (gdb) bt
> #0  __GI__exit (status=status@entry=1) at ../sysdeps/unix/sysv/linux/_exit.c:
> 27
> #1  0x00007fdac9c825ae in gdk_event_source_check 
> (base=base@entry=0x5626b0eb7770) at ../gtk/gdk/wayland/gdkeventsource.c:97
> #2  0x00007fdac962411f in g_main_context_check (context=0x5626b71d9be0, 
> max_priority=2147483647, fds=<optimized out>, n_fds=<optimized out>) at ../
> glib/glib/gmain.c:4035
> #3  0x00007fdac9679e5e in g_main_context_iterate.constprop.0 
> (context=context@entry=0x5626b71d9be0, block=block@entry=0, 
> dispatch=dispatch@entry=0, self=<optimized out>) at ../glib/glib/gmain.c:4208
> #4  0x00007fdac962132d in g_main_context_pending (context=0x5626b71d9be0) at 
> ../glib/glib/gmain.c:4241
> #5  0x00005626ab4f3bd2 in pgtk_read_socket.lto_priv ()

That's what I thought might be happening.  Emacs calls
g_main_context_pending to read events from GDK, which notices that the
display connection has been abruptly terminated, and calls _exit to
abort.

Unfortunately, there's no way for us to fix this inside Emacs, so I
guess you should look into why Wayland display connections are so
unstable on your system.