Subject: Re: bug#63283: Emacs crash within fontset

From: Eli Zaretskii <[email-masked]>
Date: Sun, 07 May 2023 09:48:48 +0300

> Date: Sat, 06 May 2023 22:36:35 +0000
> From: Seppo Ronkainen <[email-masked]>
> Cc: [email-masked]
> 
> (gdb) frame 2
> #2  0x00000055559233c4 in face_for_char (f=0x55564c8470, face=0x5556292b90, c=12302, pos=1, object=XIL(0)) at fontset.c:970
> 970       eassert (fontset_id_valid_p (face->fontset));
> (gdb) info locals
> fontset = XIL(0)
> rfont_def = XIL(0x555605b2b8)
> charset = XIL(0x300effff7380)
> face_id = 85
> id = 1432078920
> (gdb) print font_driver_list
> $1 = (struct font_driver_list *) 0x55560d77e0
> (gdb) print f->font_driver_list
> $2 = (struct font_driver_list *) 0x5556274ae0
> (gdb) frame 3
> #3  0x00000055555bd308 in FACE_FOR_CHAR (f=0x55564c8470, face=0x5556292b90, character=12302, pos=1, object=XIL(0)) at dispextern.h:1911
> (gdb) p face->font
> $5 = (struct font *) 0x0
> (gdb) p face->fontset
> $6 = -1
> (gdb) q

Thanks.  If you apply the patch below, does it avoid the abort?

> relevant commit ?
> 3c0dda2663e38635163f0fd6c19748c6eba1c3c8
> Avoid asserting for fontset validity before it is used

No, I don't think so.  We'd just abort earlier in that function.

diff --git a/src/fontset.c b/src/fontset.c
index f196dee..e004cd9 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -967,6 +967,9 @@ face_for_char (struct frame *f, struct face *face, int c,
 #endif
     }
 
+  if (face->fontset < 0 && !face->font)
+    return face->id;
+
   eassert (fontset_id_valid_p (face->fontset));
   fontset = FONTSET_FROM_ID (face->fontset);
   eassert (!BASE_FONTSET_P (fontset));