Subject: Re: bug#72692: Emacs 31.05 (40eecd594ac) get SIGSEGV on Linux (Linux 6.6.45 Kde Wayland)

From: Eli Zaretskii <[email-masked]>
Date: Wed, 28 Aug 2024 14:50:24 +0300

> From: Juri Linkov <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked],  [email-masked]
> Date: Tue, 27 Aug 2024 19:31:37 +0300
> 
> >> Reverting this line fixes the problem:
> >>
> >> -      f->face_change = true;
> >
> > Which OS is this on?  I'm having weird trouble when running the Windows
> > binary in wine, which I attribute to this change: when menu-bar-mode is
> > on, the Emacs frame raises itself whenever it loses focus.
> 
> This was on GNU/Linux (x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0),
> Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
> 
> > I see Eli reverted the change, which makes sense for now.  We'll have to
> > find another way to fix this, I think.
> 
> I'm ready to test any changes when you'll find another way to fix this.

Thanks, please test the patch below.  If it doesn't adversely affect
performance, I will install it.

diff --git a/src/xfaces.c b/src/xfaces.c
index 684b6cc..94fc59d 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -733,9 +733,13 @@ recompute_basic_faces (struct frame *f)
 {
   if (FRAME_FACE_CACHE (f))
     {
+      bool non_basic_faces_cached =
+	FRAME_FACE_CACHE (f)->used > BASIC_FACE_ID_SENTINEL;
       clear_face_cache (false);
       if (!realize_basic_faces (f))
 	emacs_abort ();
+      if (non_basic_faces_cached)
+	f->face_change = true;
     }
 }