Subject: bug#36758: 27.0.50; Mac OS/Lucid/X11: crash with libharfbuzz

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Mon, 22 Jul 2019 18:58:59 +0900

On Mon, 22 Jul 2019 17:42:02 +0900,
Simon Leinen wrote:
> 
> Dear Mitshuaru,
> 
> thank you for your prompt reply and clear instructions - this is very
> helpful for me as I don't have any experience with lldb!
> 
> > Could you try the following instructions?
> 
> >   1. recompile Emacs with CFLAGS="-O0 -g3"
> >   2. run it under lldb.
> >   3. run GNUS and wait for crash happens.
> >   4. repeat lldb "up" command until it reaches emacs`ftfont_list
> >      (frame #12 in the original stack trace)
> >   5. run "p file" under lldb.
> 
> (lldb) p file
> (FcChar8 *) $0 = 0x00000001071522e0 "/System/Library/Fonts/ArabicUIDisplay.ttc"
> 
> The file exists
> 
> : leinen@macsl[leinen]; ls -l /System/Library/Fonts/ArabicUIDisplay.ttc
> -rw-r--r--  1 root  wheel  983632 Aug 18  2018 /System/Library/Fonts/ArabicUIDisplay.ttc
> 
> Maybe the code has issue with right-to-left scripts?

Thanks.  I rather suspect it has something to do with the versions of
Harbuzz.  Could you try to see if the following test program crash on
your side?

/* cc -g hb-ot-test.c `pkg-config freetype2 harfbuzz --cflags --libs` */
#include <stdio.h>
#include <ft2build.h>
#include <freetype/freetype.h>
#include <hb.h>
#include <hb-ft.h>
#include <hb-ot.h>

int
main ()
{
  printf ("HarfBuzz Version: %s\n", hb_version_string ());

  static FT_Library ft_library;
  FT_Init_FreeType (&ft_library);

  FT_Face ft_face;
  FT_New_Face (ft_library, "/System/Library/Fonts/ArabicUIDisplay.ttc", 0,
	       &ft_face);

  hb_face_t *face = hb_ft_face_create_referenced (ft_face);
  FT_Done_Face (ft_face);

  unsigned int script_count
    = hb_ot_layout_table_get_script_tags (face, HB_OT_TAG_GSUB, 0, NULL, NULL);
  printf ("GSUB script_count = %d\n", script_count);
  script_count
    = hb_ot_layout_table_get_script_tags (face, HB_OT_TAG_GPOS, 0, NULL, NULL);
  printf ("GPOS script_count = %d\n", script_count);
}

On macOS 10.14.6 Beta, I could successfully run it with the following
output:

HarfBuzz Version: 2.5.3
GSUB script_count = 1
GPOS script_count = 1

				     YAMAMOTO Mitsuharu
				[email-masked]