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

From: NRK <nrk_AT_disroot.org>
Date: Mon, 31 Oct 2022 02:36:17 +0600

On Sun, Oct 30, 2022 at 12:50:54PM -0700, Anskrevy wrote:
> And here is my valgrind output
> https://gist.github.com/Anskrevy/b981453fb7fbe3fb410ac1dd883d23ad

Looking at the backtrace it doesn't seem like it generated anywhere from
libsl (or your program)

        ==2726510== 288 (256 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 192 of 320
        ==2726510== at 0x4841888: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
        ==2726510== by 0x49E9F25: FcPatternObjectInsertElt (fcpat.c:525)
        ==2726510== by 0x49EE180: FcPatternObjectAddWithBinding (fcpat.c:711)
        ==2726510== by 0x49FC079: UnknownInlinedFun (fcpat.c:1258)
        ==2726510== by 0x49FC079: UnknownInlinedFun (fcxml.c:3109)
        ==2726510== by 0x49FC079: FcEndElement (fcxml.c:3234)
        ==2726510== by 0x4D2E61E: doContent (xmlparse.c:3047)
        ==2726510== by 0x4D2BCB3: UnknownInlinedFun (xmlparse.c:2612)
        ==2726510== by 0x4D2BCB3: doProlog (xmlparse.c:4893)
        ==2726510== by 0x4D2D7CC: prologProcessor (xmlparse.c:4598)
        ==2726510== by 0x4D31879: XML_ParseBuffer (xmlparse.c:2009)
        ==2726510== by 0x49F67E4: FcConfigParseAndLoadFromMemoryInternal.lto_priv.0 (fcxml.c:3544)
        ==2726510== by 0x49F7136: _FcConfigParse.lto_priv.0 (fcxml.c:3679)
        ==2726510== by 0x49F7319: UnknownInlinedFun (fcxml.c:3447)
        ==2726510== by 0x49F7319: _FcConfigParse.lto_priv.0 (fcxml.c:3638)
        ==2726510== by 0x49FA2F5: UnknownInlinedFun (fcxml.c:2606)
        ==2726510== by 0x49FA2F5: FcEndElement (fcxml.c:3156)

In any case, I don't think libsl should call FcFini because we don't
know if the user is done with fontconfig or not and the FcFini
documentation states [0]:

| Frees all data structures allocated by previous calls to fontconfig
| functions. Fontconfig returns to an uninitialized state, requiring a new
| call to one of the FcInit functions before any other fontconfig function
| may be called.

The last line (requiring a new...before any other functions may be called)
makes me question if it's even okay that fontconfig functions are being
called without initializing the library.

ST calls FcInit during setup [1], dmenu/dwm doesn't. Maybe they should ?

I'm not really sure, the fontconfig documentation doesn't seem to say
anywhere (aside from that line in FcFini docs) weather initialization is
required or not.

[0]: https://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcfini.html
[1]: https://git.suckless.org/st/file/x.c.html#l1144

- NRK
Received on Sun Oct 30 2022 - 21:36:17 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 30 2022 - 21:48:09 CET