Bug 11619

Summary: libxfont BuiltinReadDirectory() has a side effect that is breaking kdrive
Product: xorg Reporter: Dodji Seketeli <dodji>
Component: Lib/XfontAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: tomi
Version: 7.2 (2007.02)   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 8888, 10713    
Attachments:
Description Flags
this patch tries to remove the side effect of the BuiltinReadDirectory() functoin none

Description Dodji Seketeli 2007-07-16 03:14:21 UTC
When BuiltinReadDirectory() is called, it changes the content of the global variable builtin_dir, defined in src/builtins/fonts.c .
It actually changes the content of the strings builtin_dir[i].file_name.

The culprit is the function FontFileAddFontFile().

The problem is that when the xserver calls BuiltinReadDirectory() twice, because it did a reset for instance, the second call does not read the same set of fonts as the first one, because builtin_dir[i].file_name got changed.

So subsquent font lookups might fail. This is what happens in bug https://bugs.freedesktop.org/show_bug.cgi?id=10713 where kdrive exits when a reset happens.

Please read comment https://bugs.freedesktop.org/show_bug.cgi?id=10713#c2 attached to that bug.
Comment 1 Dodji Seketeli 2007-07-16 03:33:14 UTC
Created attachment 10748 [details] [review]
this patch tries to remove the side effect of the BuiltinReadDirectory() functoin

Actually the side effect is not gone. What this patch does is that it saves the content of the builtin_dir and builtin_alias the first time BuiltinReadDirectory() is entered.

Subsequent calls to BuiltinReadDirectory() restores the buildin_dir and builtin_alias tables from their copies.

I have tested this in kdrive and it seems to work.

The copis of builtin_dir and builtin_alias are not freed, but this can be considered as not being a memory leak those copies are allocated only once in the process lifetime.
Comment 2 Dodji Seketeli 2007-08-13 00:48:14 UTC
This should be fixed by commit 7670d4a2720c61fbc7b989fed14c676f04ac3ad1 in libXfont master branch.

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.