[poppler] A memory leak in GlobalParams::~GlobalParams()?

Albert Astals Cid aacid at kde.org
Fri Jan 22 14:04:58 PST 2010


A Divendres, 22 de gener de 2010, mpsuzuki at hiroshima-u.ac.jp va escriure:
> Hi,
> 
> I'm quite sorry for keeping this thread.
> 
> In fontconfig mail list, Behdad proposed to use FcFini()
> to free FcConfig object. It does not require the pointer
> to FcConfig object, so it works even out of the deletion
> process of GlobalParams object, aslike:
> 
> diff --git a/utils/pdftotext.cc b/utils/pdftotext.cc
> index 4ebda19..9c6e93e 100644
> --- a/utils/pdftotext.cc
> +++ b/utils/pdftotext.cc
> @@ -337,6 +336,9 @@ int main(int argc, char *argv[]) {
>    uMap->decRefCnt();
>   err1:
>    delete globalParams;
> +#if WITH_FONTCONFIGURATION_FONTCONFIG
> +  FcFini();
> +#endif
>   err0:
> 
>    // check for memory leaks
> 
> 
> The valgrind reports no leaks. However, the strange reference
> counting issue is left in fontconfig, so FcFini() should not be
> invoked from GlobalParams::~GlobalParams().

Yeah, and this creates a ugly assimetry in which pdftotext does not do 
FcInit() but it does FcFini()

> 
> On Thu, 21 Jan 2010 19:56:06 +0000
> 
> Albert Astals Cid <aacid at kde.org> wrote:
> >A Dijous, 21 de gener de 2010, mpsuzuki at hiroshima-u.ac.jp va escriure:
> >> Do you think it's a leak but not so serious to apply
> >> my wrong patch?  I understood my patch was wrong and
> >> must be reworked. Anyway, I attached valgrind logs of
> >> pdftotext, original one (LOG-20100121a.txt) and patched
> >> one (LOG-20100121b.txt).
> >
> >I mean it is not a "real" leak, let me explain that, each application that
> >uses poppler has (or should have) exactly one GlobalParams object, that
> > gets constructed at the begining of the application and destroyed at the
> > end. So "fixing" that leak is merely a "let's make it right" issue, i do
> > not maen that it is not important, but i also mean we can perfectly live
> > without this fixed forever and noone will notice.
> 
> I see. Maybe my attempt freeing FcConfig object seems to be
> a rubbing off the text with an eraser before putting a document
> through a shredder.
> 
> Anyway, I must stop this discussion until the day when I
> find a reasonable usecase that GlobalParams (or FcConfig)
> objects are repeatedly created & deleted.
> 
> Thank you very much for patient discussion.

Thank you for caring about poppler :-)

Albert

> 
> Regards,
> mpsuzuki
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler
> 


More information about the poppler mailing list