Subject: Re: bug#33885: 27.0.50; PUA character makes emacs crash

From: Werner LEMBERG <[email-masked]>
Date: Fri, 28 Dec 2018 09:33:33 +0100 (CET)

>> Loading the attached file `bug.el' (containing the single PUA
>> character U+E6A3) with
>> 
>>   emacs -Q bug.el
>> 
>> causes a crash:
>> 
>>   xdisp.c:28955:
>>     Emacs fatal error:
>>       assertion failed:
>>         it->ascent >= 0 && it->descent >= 0
>> 
>> I've also attached the output of `bt full'.
> 
> Do you have some custom font setup, which is supposed to display this
> PUA character?

No custom setup, but...

> Because on my system, there's no font for this codepoint (as I'd
> expect),

... a font that *does* have this character (following the MUFI
standard to display characters for medieval research).

  https://folk.uib.no/hnooh/mufi/

The font in question is `Cardo Regular', Version 1.045, which you
can freely download as

  http://scholarsfonts.net/cardo104.zip

(Note that the Google variant of this font doesn't contain the MUFI
characters.)

Character U+E6A3 gets mapped to glyph 3817, `uni00720325', which is
glyph `r' with a ring below; the `ttx' font disassembler shows the
following entry from the font's `glyf' table:

  <TTGlyph name="uni00720325" xMin="52" yMin="-510" xMax="747" yMax="927">
    <component glyphName="r" x="0" y="0" flags="0x204"/>
    <component glyphName="ring" x="-39" y="-1589" flags="0x4"/>
  </TTGlyph>

> and therefore Emacs displays it as "glyphless" character, showing a
> box with the character's code in hex, and that avoids the assertion
> violation.
> 
> So please step through x_produce_glyphs when Emacs needs to produce
> a glyph for this character, and tell how you end up with both ascent
> and descent values zero.  It isn't supposed to happen with valid
> fonts.

Uh, oh, I'm completely lost in this function; nowhere I can get
information on the font's name.  Additionally, there is no repeatable
way to set a breakpoint right before the crash; the number of
iterations are different each time.

However, calling `strace' and searching for `open(' helped me identify
the last font that Emacs opened.

    Werner