Bug 229

Summary: lack of configuration file checking causes mysterious application crashes
Product: fontconfig Reporter: Marius Gedminas <marius>
Component: libraryAssignee: Keith Packard <keithp>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: high    
Version: 2.2   
Hardware: x86 (IA32)   
OS: Linux (All)   
URL: http://bugzilla.gnome.org/show_bug.cgi?id=134113
Whiteboard:
i915 platform: i915 features:

Description Marius Gedminas 2004-02-25 12:32:36 UTC
I was playing around with ~/.fonts.conf and added the following errorneous rule:

  <match target="font">
    <test name="family"><string>Lucida</string></test>
    <edit name="family" mode="prepend"><bool>sans-serif</bool></edit>
  </match>

Note <bool>sans-serif</bool>.  It should actually be <string>sans-serif</string>.

I only noticed the mistake a month or so later, when I started to investigate
mysterious Gtk+ application crashes in the font selection dialog.  The symptoms
included the following appearing in stderr:

  ** ERROR **: file pangofc-fontmap.cI: line 868
(_pango_xft_font_desc_from_pattern): assertion failed: (FcPatternGetString
(pattern, FC_FAMILY, 0, (FcChar8 **) &s) == FcResultMatch)
  aborting...

See http://bugzilla.gnome.org/show_bug.cgi?id=134113 for more details.

Fontconfig should detect and loudly complain about such mistakes in
configuration files rather than causing hard-to-diagnose trouble later on in
different components.
Comment 1 Keith Packard 2005-01-28 15:55:21 UTC
Thanks for the useful bug report.  I've gone ahead and added some polite
typechecking to the configuration file code.  With the example given, fontconfig
emits the following warnings:

Fontconfig warning: "~/.fonts.conf", line 139: "sans-serif" is not known boolean
Fontconfig warning: "~/.fonts.conf", line 139: saw bool, expected string

The first warning says that in <bool>sans-serif</bool>, the 'sans-serif' string
isn't understood as a boolean value.

The second warning says that "family" expects a string value, not a boolean value.

Does this look reasonable to you?
Comment 2 Marius Gedminas 2005-01-28 18:02:11 UTC
It's more than reasonable, thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.