Re: [dev] [libsl][bug] Call FcFini on cleanup for projects calling FcIni

From: Anskrevy <>
Date: Sun, 30 Oct 2022 12:50:54 -0700

On 10/30/22 10:47, NRK wrote:
> On Thu, Oct 27, 2022 at 01:19:28PM -0700, Anskrevy wrote:
>> Any program using libsl, or calling FcIni (directly or indirectly), that
>> does not call FcFini results in a small memory leak. dwm and dmenu are
>> effected by this.
> I do not see any call to FcInit in libsl, nor do I see any such call in
> dmenu/dwm. Running dmenu master branch under leak-sanitizer doesn't show
> any leaks related to fontconfig (v2.13.1) either.
> How exactly did you detect this leak? And are you sure this is a problem
> on libsl/dmenu/dwm side and not the library itself leaking things?
> - NRK
I was mistaken. I thought that one of the Fc calls in drw.c was
indirectly calling FcInit but after searching the fontconfig code base I
don't think that is the case.

As for how I found the leak I was using valgrind. You can try out this
small program.

Here is the Makefile

Here is the source code

And here is my valgrind output

Adding a call to FcFini in the x_cleanup function results in zero bytes
being lost.

I got similar output when using valgrind on dmenu. I believe it would be
the same with dwm but have yet to test it out yet.
Received on Sun Oct 30 2022 - 20:50:54 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 30 2022 - 21:00:08 CET