Bug 199339

Summary: desktop apps have stray file descriptor 4 open to .fonts.cache-2
Product: [Fedora] Fedora Reporter: Jon Burgess <jburgess777>
Component: fontconfigAssignee: Behdad Esfahbod <behdad>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-07-20 21:48:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Fix cache file descriptor leak none

Description Jon Burgess 2006-07-18 23:52:01 UTC
Description of problem:
Multiple KDE applications that I have open have file descriptor 4 pointing at
.fonts.cache-2

Version-Release number of selected component (if applicable):
FC5 system with all released updates as of ~18th July 2006.
[jburgess@shark Desktop]$ konsole --version
Qt: 3.3.6
KDE: 3.5.3-0.4.fc5 Fedora-Core
Konsole: 1.6.3
[jburgess@shark Desktop]$ rpm -q fontconfig
fontconfig-2.3.94-1
fontconfig-2.3.94-1


How reproducible:
Many different applications currently seem to have a file descriptor open to a
font.cache file.

Steps to Reproduce:
1. Log into KDE desktop
2. Open konsole window
3. ls -l /proc/self/fd
  
Actual results:
[jburgess@shark Desktop]$ ls -l /proc/self/fd
total 5
lrwx------ 1 jburgess jburgess 64 Jul 19 00:48 0 -> /dev/pts/8
lrwx------ 1 jburgess jburgess 64 Jul 19 00:48 1 -> /dev/pts/8
lrwx------ 1 jburgess jburgess 64 Jul 19 00:48 2 -> /dev/pts/8
lr-x------ 1 jburgess jburgess 64 Jul 19 00:48 3 -> /proc/10742/fd
lr-x------ 1 jburgess jburgess 64 Jul 19 00:48 4 ->
/home/jburgess/.rh-fontconfig/.fonts.cache-2 (deleted)

Same for bash shell too:-
[jburgess@shark Desktop]$ ls -l /proc/$$/fd
total 5
lrwx------ 1 jburgess jburgess 64 Jul 19 00:29 0 -> /dev/pts/8
lrwx------ 1 jburgess jburgess 64 Jul 19 00:29 1 -> /dev/pts/8
lrwx------ 1 jburgess jburgess 64 Jul 19 00:25 2 -> /dev/pts/8
lrwx------ 1 jburgess jburgess 64 Jul 19 00:29 255 -> /dev/pts/8
lr-x------ 1 jburgess jburgess 64 Jul 19 00:29 4 ->
/home/jburgess/.rh-fontconfig/.fonts.cache-2 (deleted)


Expected results:
fd/4 should not be open and pointing at the fonts.cache file for processes like
bash or ls.

Additional info:
I tried opening a gnome-terminal from within KDE and the gnome session didn't
have the FD open so maybe this will not be visible in a Gnome desktop.

I'm not certain this is a fontconfig bug, maybe some other process (e.g.
konsole) should be closing the cache after use, but fontconfig looks like a good
candidate to me. I understand that many apps will probably have the .font.cache
file open at some time. It looks to me like the FD is being held open after it
has been finished with or it should have been opened with FD_CLOEXEC to prevent
it being inheritted by child processes.

Comment 1 Jon Burgess 2006-07-19 01:17:29 UTC
Created attachment 132636 [details]
Fix cache file descriptor leak

This patch seems to fix the problem for me. I've posted it to
fontconfig.org for further comment.

Comment 2 Behdad Esfahbod 2006-07-20 21:48:47 UTC
Thanks, this was committed upstream.  Will be in next release.