Subject: bug#37671: 27.0.50; Segmentation fault with --fg-daemon on Linux

From: Eli Zaretskii <[email-masked]>
Date: Sat, 01 Feb 2020 14:04:48 +0200

> From: Frank Terbeck <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 01 Feb 2020 12:28:08 +0100
> 
> > What exactly did you do immediately prior to the crash?
> 
> I was reading mail using Gnus. When  I do, with an article visible, gnus
> is configured to show three windows  (Group left of Summary and Article,
> with Article below Summary). Then I switched the visible workspace in my
> X11 window manager  to somewhere emacs wasn't visible,  switched back to
> the workspace with  emacs and that's when I had  then unresponsive emacs
> window sitting there, with gdb letting me know about the segfault.
> 
> I can't tell for sure, if the crash occurred before switching workspaces
> or if that's what triggered it  — but I *think* switching workspaces was
> involved in past crashes as well. But maybe that's another coincidence.

It sounds like switching workspaces is relevant to the issue at hand.
Can you try moving the mouse pointer off the Emacs frame before
switching to the workspace where Emacs isn't visible, and moving the
mouse pointer to a place where it won't be on any Emacs frame before
switching back?  If you do that, do the crashes still happen?

Also, which window manager is the one you use?

> Anyway. I'm running my emacs inside gdb again, in case it happens again.
> Let me know if I can be of further assistance.

Thanks.  Next thing I'd like you to try is this simple band-aid:

diff --git a/src/xdisp.c b/src/xdisp.c
index 3a8b5e3..65d3ce8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -31454,6 +31454,9 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
   struct window *w = XWINDOW (hlinfo->mouse_face_window);
   struct frame *f = XFRAME (WINDOW_FRAME (w));
 
+  if (f != hlinfo->mouse_face_mouse_frame)
+    return;
+
   if (/* If window is in the process of being destroyed, don't bother
 	 to do anything.  */
       w->current_matrix != NULL