PDA

View Full Version : QFontEngineFT memory leak; harfbuzz



deepakn
27th September 2011, 13:20
Hi,

My application(Qt 4.4.3, Fed 7) consisting of Qt front end + C backend is crashing after certain set of operations. When profiled with valgrind gave the following dump:
QFontEngineFT seems to be causing the problem. I scoured the net and came to an understanding that harfbuzz is some kind of 3rdparty layout engine used by Qt. I am unable to go any further in this issue. Have anyone faced this issue before? Any pointers towards getting rid of this leak?

Can we do away with harfbuzz and make Qt use some other layout engine?

Will switching QGraphicssystem to raster do any good? (The fonts lack anti-aliasing anyways when accessed through certain versions of VNC and I am not able to fix that issue - the above mentioned switch is recommended as a fix which i am yet to try since i have to upgrade to Qt 4.5 )


==2127== 131,070 bytes in 2 blocks are still reachable in loss record 967 of 970
==2127== at 0x40054E5: malloc (vg_replace_malloc.c:149)
==2127== by 0x49AA3B0: _hb_alloc (harfbuzz-global.c:40)
==2127== by 0x49AE61C: _HB_OPEN_Load_ClassDefinition (harfbuzz-open.c:1075)
==2127== by 0x49AEB45: GSUB_Load_EmptyOrClassDefinition (harfbuzz-gsub.c:2669)
==2127== by 0x49B4CA1: Load_ChainContextSubst (harfbuzz-gsub.c:2735)
==2127== by 0x49A5944: _HB_GSUB_Load_SubTable (harfbuzz-gsub.c:4242)
==2127== by 0x49B84A2: _HB_OPEN_Load_LookupList (harfbuzz-open.c:439)
==2127== by 0x49B959C: HB_Load_GSUB_Table (harfbuzz-gsub.c:90)
==2127== by 0x49BB979: HB_NewFace (harfbuzz-shaper.cpp:966)
==2127== by 0x49C0A83: qHBNewFace(void*, HB_Error (*)(void*, unsigned, unsigned char*, unsigned*)) (qharfbuzz.cpp:113)
==2127== by 0x43B6536: QFreetypeFace::getFace(QFontEngine::FaceId const&) (qfontengine_ft.cpp:214)
==2127== by 0x43B69FD: QFontEngineFT::init(QFontEngine::FaceId, bool, QFontEngineFT::GlyphFormat) (qfontengine_ft.cpp:542)
==2127==
==2127==
==2127== 131,070 bytes in 2 blocks are still reachable in loss record 968 of 970
==2127== at 0x40054E5: malloc (vg_replace_malloc.c:149)
==2127== by 0x49AA3B0: _hb_alloc (harfbuzz-global.c:40)
==2127== by 0x49AE61C: _HB_OPEN_Load_ClassDefinition (harfbuzz-open.c:1075)
==2127== by 0x49AEB45: GSUB_Load_EmptyOrClassDefinition (harfbuzz-gsub.c:2669)
==2127== by 0x49B4A71: Load_ChainContextSubst (harfbuzz-gsub.c:2726)
==2127== by 0x49A5944: _HB_GSUB_Load_SubTable (harfbuzz-gsub.c:4242)
==2127== by 0x49B84A2: _HB_OPEN_Load_LookupList (harfbuzz-open.c:439)
==2127== by 0x49B959C: HB_Load_GSUB_Table (harfbuzz-gsub.c:90)
==2127== by 0x49BB979: HB_NewFace (harfbuzz-shaper.cpp:966)
==2127== by 0x49C0A83: qHBNewFace(void*, HB_Error (*)(void*, unsigned, unsigned char*, unsigned*)) (qharfbuzz.cpp:113)
==2127== by 0x43B6536: QFreetypeFace::getFace(QFontEngine::FaceId const&) (qfontengine_ft.cpp:214)
==2127== by 0x43B69FD: QFontEngineFT::init(QFontEngine::FaceId, bool, QFontEngineFT::GlyphFormat) (qfontengine_ft.cpp:542)
==2127==
==2127==
==2127== 157,464 bytes in 1 blocks are still reachable in loss record 969 of 970
==2127== at 0x40055E2: realloc (vg_replace_malloc.c:306)
==2127== by 0x800FE9: _XimParseStringFile (in /usr/lib/libX11.so.6.2.0)
==2127== by 0x803099: _XimLocalOpenIM (in /usr/lib/libX11.so.6.2.0)
==2127== by 0x7F5054: _XimOpenIM (in /usr/lib/libX11.so.6.2.0)
==2127== by 0x7E4D99: XOpenIM (in /usr/lib/libX11.so.6.2.0)
==2127== by 0x46AC675: QXIMInputContext::create_xim() (qximinputcontext_x11.cpp:379)
==2127== by 0x46AC890: xim_create_callback (qximinputcontext_x11.cpp:105)
==2127== by 0x803E8F: _XimRegisterIMInstantiateCallback (in /usr/lib/libX11.so.6.2.0)
==2127== by 0x7E4D47: XRegisterIMInstantiateCallback (in /usr/lib/libX11.so.6.2.0)
==2127== by 0x46ACA4D: QXIMInputContext::QXIMInputContext() (qximinputcontext_x11.cpp:362)
==2127== by 0x46AA820: QInputContextFactory::create(QString const&, QObject*) (qinputcontextfactory.cpp:131)
==2127== by 0x413E4B1: QApplication::inputContext() const (qapplication.cpp:4694)
==2127==
==2127==
==2127== 337,656 bytes in 94 blocks are still reachable in loss record 970 of 970
==2127== at 0x40054E5: malloc (vg_replace_malloc.c:149)
==2127== by 0x49AA3B0: _hb_alloc (harfbuzz-global.c:40)
==2127== by 0x49B31BB: Load_PairPos (harfbuzz-gpos.c:1062)
==2127== by 0x49A7184: _HB_GPOS_Load_SubTable (harfbuzz-gpos.c:5930)
==2127== by 0x49B8607: _HB_OPEN_Load_LookupList (harfbuzz-open.c:441)
==2127== by 0x49B930B: HB_Load_GPOS_Table (harfbuzz-gpos.c:126)
==2127== by 0x49BB9BC: HB_NewFace (harfbuzz-shaper.cpp:977)
==2127== by 0x49C0A83: qHBNewFace(void*, HB_Error (*)(void*, unsigned, unsigned char*, unsigned*)) (qharfbuzz.cpp:113)
==2127== by 0x43B6536: QFreetypeFace::getFace(QFontEngine::FaceId const&) (qfontengine_ft.cpp:214)
==2127== by 0x43B69FD: QFontEngineFT::init(QFontEngine::FaceId, bool, QFontEngineFT::GlyphFormat) (qfontengine_ft.cpp:542)
==2127== by 0x43ADD7D: QFontEngineX11FT::QFontEngineX11FT(_FcPattern*, QFontDef const&, int) (qfontengine_x11.cpp:970)
==2127== by 0x4316E90: tryPatternLoad(_FcPattern*, int, QFontDef const&, int) (qfontdatabase_x11.cpp:1621)


The leak is not a showstopper as of now. Its estimated that 10k iterations of a particular action can bring down the app which could happen in 30 days. So, effectively, if run continuously our app will crash every month - which is not bad but certainly not good acc to good programming practices. Its like you are sending the app with a time-bomb in it to the client. :confused: