This patch should help. Please try now! 2005-08-31 Patrick Lam <plam@mit.edu> * fc-cache/fc-cache.c: * src/fccache.c (FcGlobalCacheDirDestroy, FcGlobalCacheSave, FcCacheSkipToArch): * src/fcfs.c (FcFontSetSerialize): Only load requested fonts for fc-cache, and cleanup memory handling: *Serialize no longer mutates original FcPatterns, it creates a new copy in the supplied buffer. Fix thinkos in global cache freeing and in FcCacheSkipToArch. James Cloos wrote:> I gave this a test (w/o actually installing it yet). > > Running the uninstalled fc-cache (via the libtool script, of course) > resulted in a segv: > > (gdb) where > #0 0xb7d7f968 in strcmp () from /lib/tls/libc.so.6 > #1 0xb7f271ae in FcCacheSkipToArch () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 > #2 0xb7f27721 in FcGlobalCacheSave () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 > #3 0xb7f2b294 in FcConfigBuildFonts () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 > #4 0xb7f3227c in FcInitLoadConfigAndFonts () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 > #5 0xb7f324ec in FcInit () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 > #6 0x0804923a in main () > > It also seemed to ignore the directory I supplied on the command line > and scanned through all of the <dir/>s in my fonts.conf, mmap(2)ing > each font. (I only followed along via strace(1); I didn''t step thru > in gdb(1).) > > I used the -v option, and the segv occurred before anything was output. > > The dump above was w/ -v but w/o other args. > > -JimC
I gave this a test (w/o actually installing it yet). Running the uninstalled fc-cache (via the libtool script, of course) resulted in a segv: (gdb) where #0 0xb7d7f968 in strcmp () from /lib/tls/libc.so.6 #1 0xb7f271ae in FcCacheSkipToArch () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 #2 0xb7f27721 in FcGlobalCacheSave () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 #3 0xb7f2b294 in FcConfigBuildFonts () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 #4 0xb7f3227c in FcInitLoadConfigAndFonts () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 #5 0xb7f324ec in FcInit () from /home/cloos/Projects/FC/TAGS/fc-2_4_branch/src/.libs/libfontconfig.so.1 #6 0x0804923a in main () It also seemed to ignore the directory I supplied on the command line and scanned through all of the <dir/>s in my fonts.conf, mmap(2)ing each font. (I only followed along via strace(1); I didn''t step thru in gdb(1).) I used the -v option, and the segv occurred before anything was output. The dump above was w/ -v but w/o other args. -JimC -- James H. Cloos, Jr. <cloos@jhcloos.com>
Hi all, In fontconfig''s CVS branch ''fc-2_4_branch'', you''ll find a version of fontconfig that mmaps font information (FcPatterns and company) to and from disk. When you run the new fc-cache executable, it will create a ''fonts.cache-2'' file in each font-containing directory. Fontconfig will then mmap in data structures from each fonts.cache-2 file and use these fonts just like it used to. This solution is portable across platforms: fontconfig creates a signature from machine characteristics (i.e. the sizes of the relevant datatypes and the endianness) and stores multiple copies of the fonts information in each cache file. Can''t create caches in the font directories? The global per-user fonts cache still works as it did before, except that it now uses mmapable content. The only API change is to FcDirSave, which no longer takes a *dirs argument. I suppose it could, if it had to. Data structures are not observably different from before: there are some additional types in the FcValue union, but they will never be used in an FcValue that is returned to client code. The mmap is indifferent with respect to where the patterns get loaded into memory: when writing to disk, fontconfig allocates one chunk of memory per directory and writes relative pointer differences within the chunk. The pointers are reconstituted before they are passed to client code. Enjoy! Please test this branch and report any problems to me. I believe that this code is relatively solid, although I''m sure that there are some minor omissions. pat