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

From: Simon Leinen <[email-masked]>
Date: Mon, 22 Jul 2019 12:52:07 +0200

YAMAMOTO Mitsuharu writes:
> 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` */

No, that runs fine (return code 0) and outputs

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

: leinen@macsl[leinen]; objdump -macho -dylibs-used /var/tmp/a.out
/var/tmp/a.out:
	/usr/local/opt/freetype/lib/libfreetype.6.dylib (compatibility version 24.0.0, current version 24.1.0)
	/usr/local/opt/harfbuzz/lib/libharfbuzz.0.dylib (compatibility version 20504.0.0, current version 20504.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

This is the same version of libharfbuzz that my Emacs binary uses:

: leinen@macsl[leinen]; objdump -macho -dylibs-used /var/tmp/emacs/gbuild/src/emacs
/var/tmp/emacs/gbuild/src/emacs:
	/opt/X11/lib/libpng16.16.dylib (compatibility version 43.0.0, current version 43.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/opt/X11/lib/libXaw3d.8.dylib (compatibility version 9.0.0, current version 9.0.0)
	/opt/X11/lib/libXmu.6.dylib (compatibility version 9.0.0, current version 9.0.0)
	/opt/X11/lib/libXt.6.dylib (compatibility version 7.0.0, current version 7.0.0)
	/opt/X11/lib/libSM.6.dylib (compatibility version 7.0.0, current version 7.1.0)
	/opt/X11/lib/libICE.6.dylib (compatibility version 10.0.0, current version 10.0.0)
	/opt/X11/lib/libXext.6.dylib (compatibility version 11.0.0, current version 11.0.0)
	/opt/X11/lib/libX11.6.dylib (compatibility version 10.0.0, current version 10.0.0)
	/opt/X11/lib/libX11-xcb.1.dylib (compatibility version 2.0.0, current version 2.0.0)
	/opt/X11/lib/libxcb.1.dylib (compatibility version 3.0.0, current version 3.0.0)
	/opt/X11/lib/libXft.2.dylib (compatibility version 6.0.0, current version 6.2.0)
	/opt/X11/lib/libXrender.1.dylib (compatibility version 5.0.0, current version 5.0.0)
	/usr/local/opt/dbus/lib/libdbus-1.3.dylib (compatibility version 23.0.0, current version 23.11.0)
	/opt/X11/lib/libXrandr.2.dylib (compatibility version 5.0.0, current version 5.0.0)
	/opt/X11/lib/libXinerama.1.dylib (compatibility version 2.0.0, current version 2.0.0)
	/opt/X11/lib/libXfixes.3.dylib (compatibility version 5.0.0, current version 5.0.0)
	/usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 12.0.0, current version 12.9.0)
	/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
	/opt/X11/lib/libfreetype.6.dylib (compatibility version 19.0.0, current version 19.6.0)
	/opt/X11/lib/libfontconfig.1.dylib (compatibility version 11.0.0, current version 11.2.0)
	/usr/local/opt/harfbuzz/lib/libharfbuzz.0.dylib (compatibility version 20504.0.0, current version 20504.0.0)
	/usr/local/opt/gnutls/lib/libgnutls.30.dylib (compatibility version 55.0.0, current version 55.0.0)
	/usr/local/opt/little-cms2/lib/liblcms2.2.dylib (compatibility version 3.0.0, current version 3.8.0)
	/usr/local/opt/jansson/lib/libjansson.4.dylib (compatibility version 16.0.0, current version 16.1.0)
	/usr/local/opt/gmp/lib/libgmp.10.dylib (compatibility version 14.0.0, current version 14.2.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

Thanks a lot for your help! Let me know if I can run more tests for
you.  I'm optimistic that we'll find the issue soon.

Best regards,
-- 
Simon.

> #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]