[Fontconfig] FontConfig memory question

mathog mathog at caltech.edu
Fri Feb 14 23:12:26 CET 2014


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.

Did that with 2.11.  The good news: all of the leaks associated with 
text_reassemble.c in Inkscape went away.  Whatever that problem was, it 
was eliminated in the intervening versions.  The bad news: Inkscape 
still can't run FcFini() just before exit without crashing.

Ran inkscape in valgrind while it was linked with the 2.11 library 
compiled with -g, and traced a huge number of memory leaks into 
FcValueSave.  These 3 lines leak when that function is called from 
numerous locations:

	v.u.s = FcStrdup (v.u.s);
	v.u.m = FcMatrixCopy (v.u.m);
	v.u.l = FcLangSetCopy (v.u.l);

but this one doesn't

	v.u.c = FcCharSetCopy ((FcCharSet *) v.u.c);

What is this code trying to do?  Because in general

    sometype var;
    /* set the values in var */
    var = duplicate_function(var);

is going to leak if sometype has pointers to memory.  The surprising 
thing here is not that the 3 lines noted leak, but that FcCharSetCopy 
doesn't.  FcValueSave is called from 4 locations in fcpat.c, and all of 
them leaked.  The only other place FcValueSave seemed to be used was in 
fccfg.c, but that included fcaliastail.h, which redefines FcValueSave so 
that the function by that name is not called.

Regards,

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


More information about the Fontconfig mailing list