Subject: Re: bug#68940: 29.2; Random crashes in face for char / font

From: Gerd Möllmann <[email-masked]>
Date: Thu, 08 Feb 2024 11:35:46 +0100

Robert Vojta <[email-masked]> writes:

>> ../../emacs/src/lisp.h:1314: Emacs fatal error: assertion failed:
>> FIXNUMP (a)
> Message-ID: <[email-masked]>
> MIME-Version: 1.0
> Content-Type: text/plain
>
> Sorry, forgot to include the bt:
>
>     frame #8: 0x000000010027c1f8 emacs`die(msg="FIXNUMP (a)", file="../../emacs/src/lisp.h", line=1314) at alloc.c:8062:3
>     frame #9: 0x00000001003076b4 emacs`XFIXNUM(a=0x000000015b17036d) at lisp.h:1314:3
>     frame #10: 0x0000000100307198
>     emacs`font_style_to_value(prop=FONT_WEIGHT_INDEX,
>     val=0x000000015b17036d, noerror=true) at font.c:428:27

Above, the parameter val seems to be neither a symbol nor a fixnum, and
that meads to an assertion in XFIXNUM.

>     frame #11: 0x0000000100310980
>     emacs`font_select_entity(f=0x000000015b172040,
>     entities=0x0000000150ffef43, attrs=0x000000015ae06d60,
>     pixel_size=12, c=9207) at font.c:3160:5

And here, we see that val comes from a Lisp face

    FONT_SET_STYLE (prefer, FONT_WEIGHT_INDEX, attrs[LFACE_WEIGHT_INDEX]);

which could mean the parameter attrs is bogus.

>     frame #12: 0x00000001003104d0
>     emacs`font_find_for_lface(f=0x000000015b172040,
>     attrs=0x000000015ae06d60, spec=0x000000015b085a15, c=9207) at
>     font.c:3321:15

Which would mean paramter attrs above is bogus.

>   * frame #13: 0x00000001003eba14
>   emacs`fontset_find_font(fontset=0x000000014b61c99d, c=9207,
>   face=0x000000015ae06d60, charset_id=-1, fallback=false) at
>   fontset.c:732:21

Which could mean the parameter face is bogus in the above.

>     frame #14: 0x00000001003e3490
>     emacs`fontset_font(fontset=0x000000012c209205, c=9207,
>     face=0x000000015ae06d60, id=-1) at fontset.c:809:4

Same here...

>     frame #15: 0x00000001003e29a8 emacs`face_for_char(f=0x000000015b172040, face=0x000000015ae06d60, c=9207, pos=-1, object=0x0000000000000000) at fontset.c:1031:15
>     frame #16: 0x000000010031995c emacs`FACE_FOR_CHAR(f=0x000000015b172040, face=0x000000015ae06d60, character=9207, pos=-1, object=0x0000000000000000) at dispextern.h:1950:10
>     frame #17: 0x0000000100319658 emacs`Finternal_char_font(position=0x0000000000000000, ch=0x0000000000008fde) at font.c:4766:13
>
> I will inspect the fontset, face, ... values in these frames later.

Hm. I'm quite out of my comfort zone here, regarding fontsets and fonts,
but it looks to me as if we're acting on a, for some reason, invalid
face, which would come from

  face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);

in Finternal_char_font. Maybe one could take a look at *f->face_cache here?