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

From: Björn Bidar <[email-masked]>
Date: Tue, 13 Dec 2022 19:06:43 +0200

Po Lu <[email-masked]> writes:

> Björn Bidar <[email-masked]> writes:
>
>> The issue got picked up on Mastodon recently:
>> https://home.social/@[email-masked]/109505829096414816
>
> That site doesn't work for me, could you please paste an excerpt here?

This is my mastodon.el dump that should at some context, I added the
first post then my toot and Emanuel Ebassi's replies to me:

START mastdon.el dump

I do not like #Electron but I'm also not a fan of #Emacs. However, I appreciate the
self-deprecating humor.
https://cdn.fosstodon.org/media_attachments/files/109/501/742/682/624/996/original/749afb0111253dab.png
Aaron Toponce ⚛️:debian: (@[email-masked]) 2022-12-12 18:59:04

@atoponce @sotolf I think you get used to lisp, the language works just different to other
languages, after a time it's not as bad.
What usually bothers me is Emacs being single threaded quite often or using outdated
technologies such as #xembed which is now used to embedded #webkit.
The most annoying issue thou is #GTK doing funny stuff.
Like for example if you loose your display manager connection on #Wayland then GTK just
kills your application with _exit(). 
Björn (@thaodan) 2022-12-13 10:08:16 via Web
  ------------

@thaodan @atoponce @sotolf Terminating on display connection loss is recommended by the
Wayland protocol, because Wayland is not UDP: events don't get resent, and if the compositor
and the client don't agree on their state, you'll just going to crash later on. You could do
an orderly display connection drop while keeping the process alive, but a) only Emacs even
attempts this on X11 or Wayland; and b) it's not tested in toolkits because it's only needed
by Emacs 
Emmanuele Bassi (@[email-masked]) 2022-12-13 12:12:26
  ------------

@ebassi @atoponce @sotolf Never argued against closing the display connection but using _
exit() instead of exit() to make sure the program can not react is bad at best or at worst
malicious.
This issue not only affects #Emacs but any program that wants to react on loosing the
display connection. 
Björn (@thaodan) 2022-12-13 13:32:46
  ------------

@thaodan @atoponce @sotolf GTK only uses `_exit()` on remote display close. It's kind of
intentional: if the *server* terminates the connection, then there's nothing to recover from
an application side. An application can only recover if it's the one that initiated the
closing of the display connection. 
Emmanuele Bassi (@[email-masked]) 2022-12-13 13:39:09
  ------------

@ebassi @atoponce @sotolf So you decide for the application itself instead of letting the
application decide to what to do on `exit()`?
You say there's nothing to recover the applications opinion might be different. 
Björn (@thaodan) 2022-12-13 13:42:32
  ------------

@thaodan @atoponce @sotolf You cannot safely/reliably/portably do something after
server-side disconnection. We've been there with X11 first, and the same applies with
Wayland: https://bugzilla.gnome.org/show_bug.cgi?id=646338 
Emmanuele Bassi (@[email-masked]) 2022-12-13 13:50:19 ✍ 2022-12-13 17:22:14
  ------------

@atoponce @sotolf For reference the #Debuggs entry for this:
https://lists.gnu.org/r/bug-gnu-emacs/2022-08/msg00305.html 
Björn (@thaodan) 2022-12-13 13:45:57
  ------------

END mastodon.el dump 

>> Someone reported a similar issue under X11 years earlier:
>> https://bugzilla.gnome.org/show_bug.cgi?id=646338
>
> That applies only to the GDK X11 backend though, sadly.

Worth to send a patch on this? I think it might be wort to talk other
GTk developers, e.g. the one that has done the change.

Br,

Björn