On Thu, Aug 09, 2018 at 03:18:42AM +0300, Alexander Krotov wrote:
> I have reduced dmenu segfault down to a simple program:
> https://bugs.freedesktop.org/show_bug.cgi?id=107531
> 
> Please read the program and see if you can tell what is wrong or
> confirm a bug. Apparently the bug is in fontconfig.
> 
> Running dwm with "pango" patch doesn't help either, so I think the
> problem is in fontconfig and not Xft.
> 
> Also there are many bugfixes since 2.13.0 related to null ponter
> dereferences, so maybe the bug is already fixed:
> https://cgit.freedesktop.org/fontconfig/log/

> /*
> gcc bug.c -lX11 -lXft -I /usr/include/freetype2 -lfontconfig
> */
> #include <stdio.h>
> 
> #include <X11/Xlib.h>
> #include <X11/Xft/Xft.h>
> 
> int main(void) {
>       Display *dpy = XOpenDisplay(NULL);
>       if(dpy == NULL)
>               return 1;
>       int screen = DefaultScreen(dpy);
> 
>       char *fontname = "monospace:size=10";
>       XftFont *xfont = XftFontOpenName(dpy, screen, fontname);
>       if(xfont == NULL) {
>               printf("Can't load font pattern");
>               return 1;
>       }
>       FcPattern *pattern = FcNameParse((FcChar8 *) fontname);
>       if (pattern == NULL) {
>               printf("Can't parse name to pattern");
>               return 1;
>       }
>       
>       long utf8codepoint = 0x1F4D3; // notebook emoji
> 
>       FcCharSet *fccharset = FcCharSetCreate ();
>       FcCharSetAddChar(fccharset, utf8codepoint);
>       FcPatternAddCharSet(pattern, FC_CHARSET, fccharset);
>       FcPatternAddBool(pattern, FC_SCALABLE, FcTrue);
> 
>       FcConfigSubstitute(NULL, pattern, FcMatchPattern);
>       FcDefaultSubstitute(pattern);
>       FcResult result;
>       // drw.c uses XftFontMatch here
>       FcFontMatch (NULL, pattern, &result);
> 
>       XCloseDisplay(dpy);
> }

Thanks for providing a test-program.

I still cannot reproduce this bug on OpenBSD.

Do I need some specific font for it to crash? I've seen reports of issues with
the Google Noto Emoji font.

fc-match 'monospace:size=10' is 'DejaVu Sans Mono' here.

When I install Noto Emoji and change the fontname:
to:
        char *fontname = "Noto Emoji";

it still does not crash however.


I don't think using Pango is a good test, also the Pango page says:
"Client side fonts using the FreeType and fontconfig
libraries, using HarfBuzz for complex-text handling. Rendering can be with with
Cairo or Xft libraries, or directly to an in-memory buffer with no additional
libraries.".

-- 
Kind regards,
Hiltjo

Reply via email to