Subject: Re: 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 17:17:24 +0300

> Date: Mon, 19 Aug 2024 06:07:35 +0000
> From: Pip Cet <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> "Eli Zaretskii" <[email-masked]> writes:
> 
> > Where do you see this copying in realize_non_ascii_face?
> 
> static struct face *
> realize_non_ascii_face (struct frame *f, Lisp_Object font_object,
> 			struct face *base_face)
> {
>   struct face_cache *cache = FRAME_FACE_CACHE (f);
>   struct face *face;
> 
>   face = xmalloc (sizeof *face);
>   *face = *base_face;
>         ^____ here
> 
> (The entire structure is copied, and fontset isn't explicitly changed
> afterwards).

I need new glasses.

In any case, if you are right, and we free an ASCII face but leave its
non-ASCII variants unchanged, we have a much deeper problem: a
non-ASCII face is meaningless if its ASCII face was freed and
re-realized, because the non-ASCII face needs to be re-realized as
well.  So if this happens, we need to understand how and plug that
much worse problem.

In the cases I was able to reproduce on my system, the call to
realize_basic_faces was followed by setting the frame's 'face_change'
flag, which causes the next redisplay free all the frame's faces and
re-realize all of them.  (But the alpha-background parameter is not
supported here, so I needed to change other attributes.)  As long as
this happens before we try to display anything, the fact that we
uncached the fontset will not cause any harm.  IOW, the fact that the
fontset was freed and uncached in itself is not a catastrophe, as long
as the freed fontset is not accessed before it is regenerated.

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

Also, could you add to the print-outs the pointer to the face's
ascii_face, so that we see whether there's only one ASCII face
involved here or more than one?