Bug 26412 - Fonts file descriptors are not released
Summary: Fonts file descriptors are not released
Status: RESOLVED NOTABUG
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.9.7
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-03 06:35 UTC by Adrien BUSTANY
Modified: 2010-03-01 02:15 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Valgrind logs showing "leaked" fds at the top (386.53 KB, application/octet-stream)
2010-02-03 09:53 UTC, Adrien BUSTANY
Details

Description Adrien BUSTANY 2010-02-03 06:35:43 UTC
When looking at the valgrind log from a simple poppler-glib program to extract plain text content from a pdf (http://git.gnome.org/browse/tracker/tree/src/tracker-extract/tracker-extract-pdf.c) I can see that fonts fd are not released (using poppler 0.12.3). This module is loaded in another program, which will run out of free fds after a certain number of calls.

There's a patch for that in the git version of poppler : 65fba0aac7d60a0ff2ae26f21d99673de8a9de74 .
Could this patch be backported in the next stable version ? I could cherry-pick it against the 0.12.3 tag without any problem.
Comment 1 Carlos Garcia Campos 2010-02-03 09:36:46 UTC
Which poppler revision do you mean? Revision 65fba0aac7d60a0ff2ae26f21d99673de8a9de74 doesn't exist in poppler git repo. 
Comment 2 Jürg Billeter 2010-02-03 09:37:46 UTC
I think this should have been 6825a219f0bc0ac6fd469fb8a6ebb86df774375f
Comment 3 Carlos Garcia Campos 2010-02-03 09:47:10 UTC
That commit should fix the problem for you because it doesn't use CairoOutputdev anymore, but not the bug since there seems to be a leak in CairoOutputDev, maybe this one:

http://cgit.freedesktop.org/poppler/poppler/commit/?h=poppler-0.12&id=e25e4fd2e76619dd42715a1e9d78088850d8fe7e

that was comitted after 0.12.3, could you confirm this commit fixes the problem? I can backport the other commit too if it works better for you anyway. 
Comment 4 Adrien BUSTANY 2010-02-03 09:53:51 UTC
Created attachment 33034 [details]
Valgrind logs showing "leaked" fds at the top

Nope, that commit doesn't fix my bug, I still have opened file descriptors when the program exits (still the fonts). Attached is my valgrind log, the "leaked" fds are at the top.
Comment 5 Carlos Garcia Campos 2010-02-27 08:29:30 UTC
I think it's a cairo issue, we use cairo_font_face_set_user_data() to close the file descriptor when the font is destroyed, but fonts are never destroyed. Cairo holds references of the fonts that are never released. 
Comment 6 Carlos Garcia Campos 2010-02-28 01:33:06 UTC
Moving to cairo
Comment 7 Chris Wilson 2010-03-01 02:15:25 UTC
Cairo holds a large (256) scaled-font holdover cache because a lot of applications create, destroy and then recreate the small working set of fonts regularly. However, in situations such as this you will then need to exercise poppler with a large number of fonts before you see evictions. During shutdown, in order to fully clean up global caches you need to call cairo_debug_reset_static_data() [as well as all the other per library cleanup routines]. This is only recommended during leak checking, at all other times is simply more efficient to let the OS reap the resources upon exit().

Since the test case is behaving exactly as designed, I do not see the bug...


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.