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

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

>> 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>
> 
> Does this explain why the descent comes out negative?  (I'm not an
> expert on font metrics.)

No.  The `glyf' data of this glyph looks correct.

> The way I would suggest to put a useful breakpoint there is this:
> 
>   break x_produce_glyphs if it->char_to_display == 0xe6a3

OK, did that.  Here's the contents of `it' ($11), `face' ($12), and
`font' ($13), respectively, at xdisp.c:28221.  The `font' entry looks
very strange.

AFAICS, it's not a problem related to a single glyph.  We rather have
to check how the `Cardo' fonts get loaded into Emacs; it looks as if
the global font descent value is incorrect.  Please tell me (a) how to
identify the font used for U+E6A3, and (b) where to set a breakpoint
to see the font loading in action.

And indeed, ttx shows the following for the global values (in the
`hhea' table):

  <ascent value="1645"/>
  <descent value="620"/>

Compare this to, say, LiberationMono-Regular:

  <ascent value="1705"/>
  <descent value="-615"/>

So we have a font error in Cardo, setting the (Apple specific) descent
with the wrong sign.

Handling the ascent and descent in OpenType is a mess, since up to
three competing sets are present in the font.  See

  http://www.typophile.com/node/13081

for a quite exhaustive discussion.

    Werner

======================================================================

$11 = {
  window = {
    i = 0x15e8fa5
  }, 
  w = 0x15e8fa0, 
  f = 0x15e7fa0, 
  method = GET_FROM_BUFFER, 
  stop_charpos = 3, 
  prev_stop = 1, 
  base_level_stop = 0, 
  end_charpos = 3, 
  s = 0x0, 
  string_nchars = 0, 
  redisplay_end_trigger_charpos = 0, 
  multibyte_p = true, 
  header_line_p = false, 
  string_from_display_prop_p = false, 
  string_from_prefix_prop_p = false, 
  from_disp_prop_p = false, 
  ellipsis_p = false, 
  avoid_cursor_p = false, 
  dp = 0x0, 
  dpvec = 0x0, 
  dpend = 0x0, 
  dpvec_char_len = 0, 
  dpvec_face_id = 0, 
  saved_face_id = 0, 
  ctl_chars = {{
      i = 0x0
    } <repeats 16 times>}, 
  start = {
    pos = {
      charpos = 1, 
      bytepos = 1
    }, 
    overlay_string_index = -1, 
    string_pos = {
      charpos = -1, 
      bytepos = -1
    }, 
    dpvec_index = -1
  }, 
  current = {
    pos = {
      charpos = 1, 
      bytepos = 1
    }, 
    overlay_string_index = -1, 
    string_pos = {
      charpos = -1, 
      bytepos = -1
    }, 
    dpvec_index = -1
  }, 
  n_overlay_strings = 0, 
  overlay_strings_charpos = 1, 
  overlay_strings = {{
      i = 0x0
    } <repeats 16 times>}, 
  string_overlays = {{
      i = 0x0
    } <repeats 16 times>}, 
  string = {
    i = 0x0
  }, 
  from_overlay = {
    i = 0x0
  }, 
  stack = {{
      string = {
        i = 0x0
      }, 
      string_nchars = 0, 
      end_charpos = 0, 
      stop_charpos = 0, 
      prev_stop = 0, 
      base_level_stop = 0, 
      cmp_it = {
        stop_pos = 0, 
        id = 0, 
        ch = 0, 
        rule_idx = 0, 
        lookback = 0, 
        nglyphs = 0, 
        reversed_p = false, 
        charpos = 0, 
        nchars = 0, 
        nbytes = 0, 
        from = 0, 
        to = 0, 
        width = 0
      }, 
      face_id = 0, 
      u = {
        image = {
          object = {
            i = 0x0
          }, 
          slice = {
            x = {
              i = 0x0
            }, 
            y = {
              i = 0x0
            }, 
            width = {
              i = 0x0
            }, 
            height = {
              i = 0x0
            }
          }, 
          image_id = 0
        }, 
        stretch = {
          object = {
            i = 0x0
          }
        }, 
        xwidget = {
          object = {
            i = 0x0
          }
        }
      }, 
      position = {
        charpos = 0, 
        bytepos = 0
      }, 
      current = {
        pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        overlay_string_index = 0, 
        string_pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        dpvec_index = 0
      }, 
      from_overlay = {
        i = 0x0
      }, 
      area = LEFT_MARGIN_AREA, 
      method = GET_FROM_BUFFER, 
      paragraph_embedding = NEUTRAL_DIR, 
      multibyte_p = false, 
      string_from_display_prop_p = false, 
      string_from_prefix_prop_p = false, 
      display_ellipsis_p = false, 
      avoid_cursor_p = false, 
      bidi_p = false, 
      from_disp_prop_p = false, 
      line_wrap = TRUNCATE, 
      voffset = 0, 
      space_width = {
        i = 0x0
      }, 
      font_height = {
        i = 0x0
      }
    }, {
      string = {
        i = 0x0
      }, 
      string_nchars = 0, 
      end_charpos = 0, 
      stop_charpos = 0, 
      prev_stop = 0, 
      base_level_stop = 0, 
      cmp_it = {
        stop_pos = 0, 
        id = 0, 
        ch = 0, 
        rule_idx = 0, 
        lookback = 0, 
        nglyphs = 0, 
        reversed_p = false, 
        charpos = 0, 
        nchars = 0, 
        nbytes = 0, 
        from = 0, 
        to = 0, 
        width = 0
      }, 
      face_id = 0, 
      u = {
        image = {
          object = {
            i = 0x0
          }, 
          slice = {
            x = {
              i = 0x0
            }, 
            y = {
              i = 0x0
            }, 
            width = {
              i = 0x0
            }, 
            height = {
              i = 0x0
            }
          }, 
          image_id = 0
        }, 
        stretch = {
          object = {
            i = 0x0
          }
        }, 
        xwidget = {
          object = {
            i = 0x0
          }
        }
      }, 
      position = {
        charpos = 0, 
        bytepos = 0
      }, 
      current = {
        pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        overlay_string_index = 0, 
        string_pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        dpvec_index = 0
      }, 
      from_overlay = {
        i = 0x0
      }, 
      area = LEFT_MARGIN_AREA, 
      method = GET_FROM_BUFFER, 
      paragraph_embedding = NEUTRAL_DIR, 
      multibyte_p = false, 
      string_from_display_prop_p = false, 
      string_from_prefix_prop_p = false, 
      display_ellipsis_p = false, 
      avoid_cursor_p = false, 
      bidi_p = false, 
      from_disp_prop_p = false, 
      line_wrap = TRUNCATE, 
      voffset = 0, 
      space_width = {
        i = 0x0
      }, 
      font_height = {
        i = 0x0
      }
    }, {
      string = {
        i = 0x0
      }, 
      string_nchars = 0, 
      end_charpos = 0, 
      stop_charpos = 0, 
      prev_stop = 0, 
      base_level_stop = 0, 
      cmp_it = {
        stop_pos = 0, 
        id = 0, 
        ch = 0, 
        rule_idx = 0, 
        lookback = 0, 
        nglyphs = 0, 
        reversed_p = false, 
        charpos = 0, 
        nchars = 0, 
        nbytes = 0, 
        from = 0, 
        to = 0, 
        width = 0
      }, 
      face_id = 0, 
      u = {
        image = {
          object = {
            i = 0x0
          }, 
          slice = {
            x = {
              i = 0x0
            }, 
            y = {
              i = 0x0
            }, 
            width = {
              i = 0x0
            }, 
            height = {
              i = 0x0
            }
          }, 
          image_id = 0
        }, 
        stretch = {
          object = {
            i = 0x0
          }
        }, 
        xwidget = {
          object = {
            i = 0x0
          }
        }
      }, 
      position = {
        charpos = 0, 
        bytepos = 0
      }, 
      current = {
        pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        overlay_string_index = 0, 
        string_pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        dpvec_index = 0
      }, 
      from_overlay = {
        i = 0x0
      }, 
      area = LEFT_MARGIN_AREA, 
      method = GET_FROM_BUFFER, 
      paragraph_embedding = NEUTRAL_DIR, 
      multibyte_p = false, 
      string_from_display_prop_p = false, 
      string_from_prefix_prop_p = false, 
      display_ellipsis_p = false, 
      avoid_cursor_p = false, 
      bidi_p = false, 
      from_disp_prop_p = false, 
      line_wrap = TRUNCATE, 
      voffset = 0, 
      space_width = {
        i = 0x0
      }, 
      font_height = {
        i = 0x0
      }
    }, {
      string = {
        i = 0x0
      }, 
      string_nchars = 0, 
      end_charpos = 0, 
      stop_charpos = 0, 
      prev_stop = 0, 
      base_level_stop = 0, 
      cmp_it = {
        stop_pos = 0, 
        id = 0, 
        ch = 0, 
        rule_idx = 0, 
        lookback = 0, 
        nglyphs = 0, 
        reversed_p = false, 
        charpos = 0, 
        nchars = 0, 
        nbytes = 0, 
        from = 0, 
        to = 0, 
        width = 0
      }, 
      face_id = 0, 
      u = {
        image = {
          object = {
            i = 0x0
          }, 
          slice = {
            x = {
              i = 0x0
            }, 
            y = {
              i = 0x0
            }, 
            width = {
              i = 0x0
            }, 
            height = {
              i = 0x0
            }
          }, 
          image_id = 0
        }, 
        stretch = {
          object = {
            i = 0x0
          }
        }, 
        xwidget = {
          object = {
            i = 0x0
          }
        }
      }, 
      position = {
        charpos = 0, 
        bytepos = 0
      }, 
      current = {
        pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        overlay_string_index = 0, 
        string_pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        dpvec_index = 0
      }, 
      from_overlay = {
        i = 0x0
      }, 
      area = LEFT_MARGIN_AREA, 
      method = GET_FROM_BUFFER, 
      paragraph_embedding = NEUTRAL_DIR, 
      multibyte_p = false, 
      string_from_display_prop_p = false, 
      string_from_prefix_prop_p = false, 
      display_ellipsis_p = false, 
      avoid_cursor_p = false, 
      bidi_p = false, 
      from_disp_prop_p = false, 
      line_wrap = TRUNCATE, 
      voffset = 0, 
      space_width = {
        i = 0x0
      }, 
      font_height = {
        i = 0x0
      }
    }, {
      string = {
        i = 0x0
      }, 
      string_nchars = 0, 
      end_charpos = 0, 
      stop_charpos = 0, 
      prev_stop = 0, 
      base_level_stop = 0, 
      cmp_it = {
        stop_pos = 0, 
        id = 0, 
        ch = 0, 
        rule_idx = 0, 
        lookback = 0, 
        nglyphs = 0, 
        reversed_p = false, 
        charpos = 0, 
        nchars = 0, 
        nbytes = 0, 
        from = 0, 
        to = 0, 
        width = 0
      }, 
      face_id = 0, 
      u = {
        image = {
          object = {
            i = 0x0
          }, 
          slice = {
            x = {
              i = 0x0
            }, 
            y = {
              i = 0x0
            }, 
            width = {
              i = 0x0
            }, 
            height = {
              i = 0x0
            }
          }, 
          image_id = 0
        }, 
        stretch = {
          object = {
            i = 0x0
          }
        }, 
        xwidget = {
          object = {
            i = 0x0
          }
        }
      }, 
      position = {
        charpos = 0, 
        bytepos = 0
      }, 
      current = {
        pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        overlay_string_index = 0, 
        string_pos = {
          charpos = 0, 
          bytepos = 0
        }, 
        dpvec_index = 0
      }, 
      from_overlay = {
        i = 0x0
      }, 
      area = LEFT_MARGIN_AREA, 
      method = GET_FROM_BUFFER, 
      paragraph_embedding = NEUTRAL_DIR, 
      multibyte_p = false, 
      string_from_display_prop_p = false, 
      string_from_prefix_prop_p = false, 
      display_ellipsis_p = false, 
      avoid_cursor_p = false, 
      bidi_p = false, 
      from_disp_prop_p = false, 
      line_wrap = TRUNCATE, 
      voffset = 0, 
      space_width = {
        i = 0x0
      }, 
      font_height = {
        i = 0x0
      }
    }}, 
  sp = 0, 
  selective = 0, 
  what = IT_CHARACTER, 
  face_id = 17, 
  selective_display_ellipsis_p = true, 
  ctl_arrow_p = true, 
  face_box_p = false, 
  start_of_box_run_p = false, 
  end_of_box_run_p = false, 
  overlay_strings_at_end_processed_p = false, 
  ignore_overlay_strings_at_pos_p = false, 
  glyph_not_available_p = false, 
  starts_in_middle_of_char_p = false, 
  face_before_selective_p = false, 
  constrain_row_ascent_descent_p = false, 
  line_number_produced_p = false, 
  line_wrap = WINDOW_WRAP, 
  base_face_id = 0, 
  c = 59043, 
  len = 3, 
  cmp_it = {
    stop_pos = 1, 
    id = -1, 
    ch = -2, 
    rule_idx = 0, 
    lookback = 0, 
    nglyphs = 0, 
    reversed_p = false, 
    charpos = 0, 
    nchars = 0, 
    nbytes = 0, 
    from = 0, 
    to = 0, 
    width = 0
  }, 
  char_to_display = 59043, 
  glyphless_method = GLYPHLESS_DISPLAY_THIN_SPACE, 
  image_id = 0, 
  xwidget = 0x0, 
  slice = {
    x = {
      i = 0x0
    }, 
    y = {
      i = 0x0
    }, 
    width = {
      i = 0x0
    }, 
    height = {
      i = 0x0
    }
  }, 
  space_width = {
    i = 0x0
  }, 
  voffset = 0, 
  tab_width = 8, 
  font_height = {
    i = 0x0
  }, 
  object = {
    i = 0x120c2e5
  }, 
  position = {
    charpos = 1, 
    bytepos = 1
  }, 
  truncation_pixel_width = 0, 
  continuation_pixel_width = 11, 
  first_visible_x = 0, 
  last_visible_x = 880, 
  last_visible_y = 850, 
  extra_line_spacing = 0, 
  max_extra_line_spacing = 0, 
  override_ascent = -1, 
  override_descent = 0, 
  override_boff = 0, 
  glyph_row = 0x1c06800, 
  area = TEXT_AREA, 
  nglyphs = 1, 
  pixel_width = 0, 
  ascent = 0, 
  descent = 0, 
  max_ascent = 0, 
  max_descent = 0, 
  phys_ascent = 0, 
  phys_descent = 0, 
  max_phys_ascent = 0, 
  max_phys_descent = 0, 
  current_x = 0, 
  continuation_lines_width = 0, 
  eol_pos = {
    charpos = 0, 
    bytepos = 0
  }, 
  current_y = 0, 
  first_vpos = 0, 
  vpos = 0, 
  hpos = 0, 
  lnum = 0, 
  lnum_bytepos = 0, 
  lnum_width = 0, 
  lnum_pixel_width = 0, 
  pt_lnum = 0, 
  tab_offset = 0, 
  left_user_fringe_bitmap = 0, 
  right_user_fringe_bitmap = 0, 
  left_user_fringe_face_id = 0, 
  right_user_fringe_face_id = 0, 
  bidi_p = true, 
  bidi_it = {
    bytepos = 1, 
    charpos = 1, 
    ch = 59043, 
    nchars = 1, 
    ch_len = 3, 
    type = STRONG_L, 
    type_after_wn = STRONG_L, 
    orig_type = STRONG_L, 
    resolved_level = 0 '\000', 
    isolate_level = 0 '\000', 
    invalid_levels = 0, 
    invalid_isolates = 0, 
    prev = {
      charpos = 1, 
      type = NEUTRAL_B, 
      orig_type = NEUTRAL_B
    }, 
    last_strong = {
      charpos = 0, 
      type = UNKNOWN_BT, 
      orig_type = UNKNOWN_BT
    }, 
    next_for_neutral = {
      charpos = -1, 
      type = UNKNOWN_BT, 
      orig_type = UNKNOWN_BT
    }, 
    prev_for_neutral = {
      charpos = 1, 
      type = STRONG_L, 
      orig_type = UNKNOWN_BT
    }, 
    next_for_ws = {
      charpos = -1, 
      type = UNKNOWN_BT, 
      orig_type = UNKNOWN_BT
    }, 
    bracket_pairing_pos = -1, 
    bracket_enclosed_type = UNKNOWN_BT, 
    next_en_pos = 0, 
    next_en_type = UNKNOWN_BT, 
    sos = L2R, 
    scan_dir = 1, 
    disp_pos = 3, 
    disp_prop = 0, 
    stack_idx = 0, 
    level_stack = {{
        next_for_neutral_pos = 0, 
        next_for_neutral_type = 0, 
        last_strong_type = 0, 
        prev_for_neutral_type = 0, 
        level = 0 '\000', 
        flags = 0 '\000'
      } <repeats 128 times>}, 
    string = {
      lstring = {
        i = 0x0
      }, 
      s = 0x0, 
      schars = 0, 
      bufpos = 0, 
      from_disp_str = false, 
      unibyte = false
    }, 
    w = 0x15e8fa0, 
    paragraph_dir = L2R, 
    separator_limit = -1, 
    first_elt = false, 
    new_paragraph = false, 
    frame_window_p = true
  }, 
  paragraph_embedding = L2R
}
$12 = {
  lface = {{
      i = 0x5970
    }, {
      i = 0x1b645e4
    }, {
      i = 0x1b64624
    }, {
      i = 0x9de0
    }, {
      i = 0x1b2
    }, {
      i = 0x9de0
    }, {
      i = 0x9de0
    }, {
      i = 0x0
    }, {
      i = 0x0
    }, {
      i = 0x1b6ec74
    }, {
      i = 0x1b6ec94
    }, {
      i = 0x0
    }, {
      i = 0x0
    }, {
      i = 0x0
    }, {
      i = 0x0
    }, {
      i = 0x15f0085
    }, {
      i = 0x0
    }, {
      i = 0x1b720a4
    }, {
      i = 0xd5f0
    }}, 
  id = 17, 
  gc = 0x0, 
  stipple = 0, 
  foreground = 0, 
  background = 16777215, 
  underline_color = 0, 
  overline_color = 0, 
  strike_through_color = 0, 
  box_color = 0, 
  font = 0x226b780, 
  fontset = 3, 
  box_line_width = 0, 
  box = FACE_NO_BOX, 
  underline_type = FACE_UNDER_LINE, 
  use_box_color_for_shadows_p = false, 
  underline_p = false, 
  overline_p = false, 
  strike_through_p = false, 
  foreground_defaulted_p = false, 
  background_defaulted_p = false, 
  underline_defaulted_p = false, 
  overline_color_defaulted_p = false, 
  strike_through_color_defaulted_p = false, 
  box_color_defaulted_p = false, 
  tty_bold_p = false, 
  tty_italic_p = false, 
  tty_underline_p = false, 
  tty_reverse_p = false, 
  colors_copied_bitwise_p = true, 
  overstrike = false, 
  hash = 1344140, 
  next = 0x0, 
  prev = 0x191c150, 
  ascii_face = 0x191c150, 
  extra = 0x0
}
$13 = {
  header = {
    size = 4611686018880454673
  }, 
  props = {{
      i = 0xe7f0
    }, {
      i = 0x11d8390
    }, {
      i = 0x11d83c0
    }, {
      i = 0x0
    }, {
      i = 0x7f50
    }, {
      i = 0x19142
    }, {
      i = 0x19082
    }, {
      i = 0x19102
    }, {
      i = 0x4e
    }, {
      i = 0x0
    }, {
      i = 0x0
    }, {
      i = 0x2
    }, {
      i = 0x211e4b3
    }, {
      i = 0x0
    }, {
      i = 0x1cf1da4
    }, {
      i = 0x1cf1dc4
    }, {
      i = 0x20445d4
    }}, 
  min_width = 5, 
  max_width = 5, 
  pixel_size = 19, 
  height = 11, 
  space_width = 5, 
  average_width = 10, 
  ascent = 16, 
  descent = -5, 
  underline_thickness = 0, 
  underline_position = 1, 
  vertical_centering = false, 
  baseline_offset = 0, 
  relative_compose = 0, 
  default_ascent = 0, 
  encoding_charset = -1, 
  repertory_charset = -1, 
  driver = 0x7b5fa0 <xftfont_driver>
}