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

From: Eli Zaretskii <[email-masked]>
Date: Mon, 19 Aug 2024 19:49:03 +0300

> Date: Mon, 19 Aug 2024 16:34:59 +0000
> From: Pip Cet <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> "Eli Zaretskii" <[email-masked]> writes:
> 
> > Thanks, but I'd also like to see the callers which call
> > free_realized_face in a way that causes the latter to call
> > free_face_fontset.  That's why I asked for backtraces from those
> > calls, but I don't think you sent such backtraces.  What you sent was
> 
> Just for the record, you asked:
> 
> > So can you show a backtrace from the call to free_realized_faces
> > (supposedly called by realize_basic_faces?) which causes these
> > printfs:
> > > fontset 103 used for face 0x117cca0
> > > fontset 103 used for face 0x2a7a3c0
> > > fontset 103 used for face 0x117cca0
> > > fontset 103 used for face 0x2a62860
> 
> ... which I misunderstood.  Sorry.

Sorry for being unclear.

> Is this what you want?

Yes, recompute_basic_faces was the prime suspect.  I think we added
several calls to it over the last years, to fix problems with face
cache being emptied at some unexpected times.

> Indeed, I can report that the bug doesn't seem to occur after this
> simple change:
> 
> diff --git a/src/xfaces.c b/src/xfaces.c
> index 684b6ccfac7..a4ac9c0787a 100644
> --- a/src/xfaces.c
> +++ b/src/xfaces.c
> @@ -736,6 +736,7 @@ recompute_basic_faces (struct frame *f)
>        clear_face_cache (false);
>        if (!realize_basic_faces (f))
>         emacs_abort ();
> +      f->face_change = true;
>      }
>  }
>  
> 
> So something like that (though moving the call down into
> realize_basic_faces or even further would be good) would probably work
> for the OP, and emacs-30?

I think setting the flag in recompute_basic_faces should be enough.
Let me think about it some more.