[Fontconfig] FontConfig memory question

mathog mathog at caltech.edu
Sat Feb 15 01:06:47 CET 2014


On 14-Feb-2014 15:10, Behdad Esfahbod wrote:
> On Feb 14, 2014 5:12 PM, "mathog" <mathog at caltech.edu> wrote:
>> 
>> On 14-Feb-2014 11:47, mathog wrote:
>>> 
>>> I'm thinking it will probably come down to building a debug version 
>>> of
>>> fontconfig, linking with that, and then tracking a whole lot of
>>> pointers.
>> 
>> 
>>  The bad news: Inkscape still can't run FcFini() just before exit 
>> without
> crashing.
> 
> Try:
> 
>   pango_cairo_font_map_set_default (NULL);
>   cairo_debug_reset_static_data ();
>   FcFini ();


Still crashes, just in a different place.  It logs this to the terminal

inkscape: /build/buildd/cairo-1.10.2/src/cairo-hash.c:196: 
_cairo_hash_table_destroy: Assertion `hash_table->live_entries == 0' 
failed.

and a back trace in gdb shows that it failed in the 
cairo_debug_reset_static_data() function

A question about data storage in fontconfig.  The FcValue looks like 
this:

typedef struct _FcValue {
     FcType	type;
     union {
	const FcChar8	*s;
	int		i;
	FcBool		b;
	double		d;
	const FcMatrix	*m;
	const FcCharSet	*c;
	void		*f;
	const FcLangSet	*l;
     } u;
} FcValue;

and the memory for "s", for instance, is released this way:

	FcFree (v.u.s);

and in other locations one finds things like:

FcPatternObjectGetString (const FcPattern *p, FcObject object, int id, 
FcChar8 ** s)
{
    /* lines removed */

     *s = (FcChar8 *) v.u.s;

Maybe I have this wrong, but in C if

   const char *ccptr;

aren't both

   char *cptr = (char *)ccptr;

and

   free((char *)ccptr);

undefined operations?   Now it may well be that a particular compiler 
does what the programmer wants in those fontconfig lines, but I'm not 
sure that the C language specification says that it has to.


Thanks,

David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech


More information about the Fontconfig mailing list