Valgrind show leaks on simple project
I tried to build simple example with libXft here https://github.com/jsynacek/xft-example/blob/master/main.c
But got leaks inside libfontconfig (libfontconfig i builded by own hands ver. 2.13.94)
See log below
- ==22809== Memcheck, a memory error detector
- ==22809== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
- ==22809== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
- ==22809== Command: ./test_xft_fc.out
- ==22809== Parent PID: 4503
- ==22809==
- ==22809==
- ==22809== HEAP SUMMARY:
- ==22809== in use at exit: 448,596 bytes in 7,271 blocks
- ==22809== total heap usage: 18,096 allocs, 10,825 frees, 4,752,662 bytes allocated
- ==22809==
- ==22809== 288 (256 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 191 of 271
- ==22809== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
- ==22809== by 0x4C0993D: FcPatternObjectInsertElt (fcpat.c:545)
- ==22809== by 0x4C0A06F: FcPatternObjectAddWithBinding (fcpat.c:732)
- ==22809== by 0x4C0BB7E: FcPatternAppend (fcpat.c:1281)
- ==22809== by 0x4C1687D: FcParsePattern (fcxml.c:3087)
- ==22809== by 0x4C16B9C: FcEndElement (fcxml.c:3212)
- ==22809== by 0x4F179D9: ??? (in /usr/lib/x86_64-linux-gnu/libexpat.so.1.6.11)
- ==22809== by 0x4F186AF: ??? (in /usr/lib/x86_64-linux-gnu/libexpat.so.1.6.11)
- ==22809== by 0x4F15B82: ??? (in /usr/lib/x86_64-linux-gnu/libexpat.so.1.6.11)
- ==22809== by 0x4F1704D: ??? (in /usr/lib/x86_64-linux-gnu/libexpat.so.1.6.11)
- ==22809== by 0x4F1ADBF: XML_ParseBuffer (in /usr/lib/x86_64-linux-gnu/libexpat.so.1.6.11)
- ==22809== by 0x4C173D8: FcConfigParseAndLoadFromMemoryInternal (fcxml.c:3527)
- ==22809==
- ==22809== 416 (256 direct, 160 indirect) bytes in 1 blocks are definitely lost in loss record 196 of 271
- ==22809== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
- ==22809== by 0x4C0993D: FcPatternObjectInsertElt (fcpat.c:545)
- ==22809== by 0x4C0A06F: FcPatternObjectAddWithBinding (fcpat.c:732)
- ==22809== by 0x4C0A148: FcPatternObjectAdd (fcpat.c:761)
- ==22809== by 0x4C0A4A1: FcPatternObjectAddDouble (fcpat.c:856)
- ==22809== by 0x4C0A4E1: FcPatternAddDouble (fcpat.c:863)
- ==22809== by 0x49A72B2: ??? (in /usr/lib/x86_64-linux-gnu/libXft.so.2.3.3)
- ==22809== by 0x49A75BC: ??? (in /usr/lib/x86_64-linux-gnu/libXft.so.2.3.3)
- ==22809== by 0x49A788E: ??? (in /usr/lib/x86_64-linux-gnu/libXft.so.2.3.3)
- ==22809== by 0x49A7CF1: XftDefaultHasRender (in /usr/lib/x86_64-linux-gnu/libXft.so.2.3.3)
- ==22809== by 0x49A812F: XftDefaultSubstitute (in /usr/lib/x86_64-linux-gnu/libXft.so.2.3.3)
- ==22809== by 0x49AACBD: XftFontMatch (in /usr/lib/x86_64-linux-gnu/libXft.so.2.3.3)
- ==22809==
- ==22809== 2,520 (768 direct, 1,752 indirect) bytes in 1 blocks are definitely lost in loss record 232 of 271
- ==22809== at 0x483DFAF: realloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
- ==22809== by 0x4C098DB: FcPatternObjectInsertElt (fcpat.c:536)
- ==22809== by 0x4C09EB3: FcPatternObjectListAdd (fcpat.c:670)
- ==22809== by 0x4C05286: FcFontRenderPrepare (fcmatch.c:822)
- ==22809== by 0x4C05BA9: FcFontMatch (fcmatch.c:1025)
- ==22809== by 0x49AACD7: XftFontMatch (in /usr/lib/x86_64-linux-gnu/libXft.so.2.3.3)
- ==22809== by 0x49AAFEB: XftFontOpenName (in /usr/lib/x86_64-linux-gnu/libXft.so.2.3.3)
- ==22809== by 0x1094FE: main (main.cpp:36)
- ==22809==
- ==22809== LEAK SUMMARY:
- ==22809== definitely lost: 1,280 bytes in 3 blocks
- ==22809== indirectly lost: 1,944 bytes in 66 blocks
- ==22809== possibly lost: 0 bytes in 0 blocks
- ==22809== still reachable: 445,372 bytes in 7,202 blocks
- ==22809== suppressed: 0 bytes in 0 blocks
- ==22809== Reachable blocks (those to which a pointer was found) are not shown.
- ==22809== To see them, rerun with: --leak-check=full --show-leak-kinds=all
- ==22809==
- ==22809== For lists of detected and suppressed errors, rerun with: -s
- ==22809== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
it seems this issue #77 very similar to my but has no full information.
Full story begins from my big project which i developing and build on my ubuntu 20.04 LTS - but when i started to test my project with valgrind i've got leaks inside libfontconfig. Then i began to exploring this problem and downloaded ver. 2.13.94 in the hope that it has already been fixed there - but i see problem still persists.
I am just began to investigate the code but it seems some of malloc'ed(or realloc'ed) FcPatternElt not freed by FcPatternDestroy
More details of my assumption perhaps i can tell on this week