Bug 100278 - X11 fc-cache and XQuartz fc-cache disagree, causing 100% CPU at every start of XQuartz
Summary: X11 fc-cache and XQuartz fc-cache disagree, causing 100% CPU at every start o...
Status: RESOLVED MOVED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: fc-cache (show other bugs)
Version: 2.12
Hardware: x86-64 (AMD64) Mac OS X (All)
: medium normal
Assignee: fontconfig-bugs
QA Contact: Behdad Esfahbod
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-19 11:42 UTC by Jörg Höhle
Modified: 2018-08-20 21:46 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Jörg Höhle 2017-03-19 11:42:33 UTC
Hi,

I recently installed XQuartz 2.7.11 (incl. fontconfig 2.12) on my OSX 10.6.8 64 bit Mac Mini machine, upgrading from Apple's X11 (2.3.6). When XQuartz starts, the CPU gets 100% busy for one minute, while two instances of fc-cache produce error messages. One instance is reported as org.macosforge.xquartz.privileged_startx, the other is org.macosforge.xquartz.startx in Konsole.app.

What seems to distinguish my bug report from other ones about fc-cache is that X11 fc-cache and XQuartz disagree. X11 fc-cache finds everything is fine, while XQuartz fc-cache wants to recache *every* directory and fails at that, each time XQuartz starts.
Otherwise, it seems very similar to the old https://github.com/XQuartz/xquartz-old-tickets/blob/master/ticket/820.md about 2.7.5.

So the issue is:
A) Either disagreement is normal, e.g. because the file format changed; (But then, how can X11 still run after installing XQuartz?)
  In that case, the present issue is about a bug in the XQuartz installer process, which should have generated proper caches initially.
B) Or XQuartz fc-cache is wrong, for whatever reason; the caches are fine and fc-cache should be quiet and exit fast.

I don't believe that the installation process failed. "ls -alt" shows that some root-owned files named fonts.* were created when I installed XQuartz last week:
$ LANG=C ls -alt /opt/X11/share/fonts/misc
-rw-r--r--    1 root  wheel   32637 Mar 12 20:50 fonts.dir
drwxr-xr-x  416 root  wheel   14144 Mar 12 20:49 .
-rw-r--r--    1 root  wheel    4268 Mar 12 20:49 encodings.dir
-rw-r--r--    1 root  wheel       2 Mar 12 20:49 fonts.scale
-rw-r--r--    1 root  wheel   19562 Mar 12 20:49 fonts.list
-rw-r--r--    1 root  wheel    6270 Oct  7 19:23 fonts.alias
-rw-r--r--    1 root  wheel    1371 Oct  7 19:23 olcursor.pcf.gz
[...]

Note that in /usr/X11R6/lib/X11/fonts/ no files were updated, except in encodings/
$ ls -alt /usr/X11R6/lib/X11/fonts/misc
-rw-r--r--    1 root  wheel   32637 Feb  2  2013 fonts.dir
drwxr-xr-x  416 root  wheel   14144 Feb  2  2013 .
-rw-r--r--    1 root  wheel    4456 Feb  2  2013 encodings.dir
-rw-r--r--    1 root  wheel       2 Feb  2  2013 fonts.scale
[...]
$ ls -alt /usr/X11R6/lib/X11/fonts/encodings
drwxr-xr-x  38 root  wheel  1292 Mar 19 09:07 .
-rw-r--r--   1 root  wheel  4456 Mar 19 09:07 encodings.dir
drwxr-xr-x  12 root  wheel   408 May 19  2009 ..
-rw-r--r--   1 root  wheel   616 May 19  2009 microsoft-cp1250.enc.gz
[...]
Is that how the files should be?

What I don't understand is why xquartz.privileged_startx equally fails to write caches, as it seems to run as root, whereas xquartz.startx runs under the normal login UID, according to the Activity Monitor.app.

Here is X11's fc-cache -v output (edited for brevity):
/usr/X11/lib/X11/fonts: skipping, existing cache is valid: 0 fonts, 10 dirs
/usr/X11/..fonts/100dpi: skipping, existing cache is valid: 398 fonts, 0 dirs
[...]
/usr/X11/..fonts/encodings: skipping, existing cache is valid: 0 fonts, 1 dirs
/usr/X11/..fonts/encodings/large: skipping, existing cache is valid: 0 fonts, 0 dirs
/usr/X11/..fonts/misc: skipping, existing cache is valid: 59 fonts, 0 dirs
/usr/X11/..fonts/util: skipping, existing cache is valid: 0 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts: skipping, existing cache is valid: 0 fonts, 10 dirs
/usr/X11R6/..fonts/100dpi: skipping, existing cache is valid: 398 fonts, 0 dirs
[...]
/usr/X11R6/..fonts/encodings: skipping, existing cache is valid: 0 fonts, 1 dirs
/usr/X11R6/..fonts/encodings/large: skipping, existing cache is valid: 0 fonts, 0 dirs
/usr/X11R6/..fonts/misc: skipping, existing cache is valid: 59 fonts, 0 dirs
/usr/X11R6/..fonts/util: skipping, existing cache is valid: 0 fonts, 0 dirs
/Users/foobar/.fonts: skipping, no such directory
/System/Library/Fonts: skipping, existing cache is valid: 69 fonts, 0 dirs
/Library/Fonts: skipping, existing cache is valid: 211 fonts, 0 dirs
/Users/foobar/Library/Fonts: skipping, existing cache is valid: 0 fonts, 0 dirs
/usr/X11/var/cache/fontconfig: not cleaning unwritable cache directory
/Users/foobar/.fontconfig: cleaning cache directory
fc-cache: succeeded

For comparison, XQuartz output:
$ time fc-cache -v
/opt/X11/share/fonts: caching, new cache contents: 0 fonts, 10 dirs
/opt/X11/share/fonts: failed to write cache
/opt/X11/share/fonts/100dpi: caching, new cache contents: 398 fonts, 0 dirs
/opt/X11/share/fonts/100dpi: failed to write cache
[...]
/opt/X11/share/fonts/encodings: caching, new cache contents: 0 fonts, 1 dirs
/opt/X11/share/fonts/encodings: failed to write cache
/opt/X11/share/fonts/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/opt/X11/share/fonts/encodings/large: failed to write cache
/opt/X11/share/fonts/misc: caching, new cache contents: 59 fonts, 0 dirs
/opt/X11/share/fonts/misc: failed to write cache
/opt/X11/share/fonts/util: caching, new cache contents: 0 fonts, 0 dirs
/opt/X11/share/fonts/util: failed to write cache
/usr/X11R6/lib/X11/fonts: caching, new cache contents: 0 fonts, 10 dirs
/usr/X11R6/lib/X11/fonts: failed to write cache
/usr/X11R6/lib/X11/fonts/100dpi: caching, new cache contents: 398 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts/100dpi: failed to write cache
[...]
/usr/X11R6/lib/X11/fonts/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/X11R6/lib/X11/fonts/encodings: failed to write cache
/usr/X11R6/lib/X11/fonts/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts/encodings/large: failed to write cache
/usr/X11R6/lib/X11/fonts/misc: caching, new cache contents: 59 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts/misc: failed to write cache
/usr/X11R6/lib/X11/fonts/util: caching, new cache contents: 0 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts/util: failed to write cache
/Users/foobar/.local/share/fonts: skipping, no such directory
/Users/foobar/.fonts: skipping, no such directory
/System/Library/Fonts: caching, new cache contents: 61 fonts, 0 dirs
/System/Library/Fonts: failed to write cache
/Library/Fonts: caching, new cache contents: 218 fonts, 0 dirs
/Library/Fonts: failed to write cache
/Users/foobar/Library/Fonts: caching, new cache contents: 0 fonts, 0 dirs
/Users/foobar/Library/Fonts: failed to write cache
/opt/X11/var/cache/fontconfig: not cleaning unwritable cache directory
/Users/foobar/.cache/fontconfig: cleaning cache directory
/Users/foobar/.fontconfig: cleaning cache directory
fc-cache: failed
real	  0m54.362s
user	  0m49.486s
sys	  0m1.398s

So do X11 and XQuartz 2.7.11 share a common (or at least downward compatible) cache format?
What's causing XQuartz to believe the caches need rebuilding?
Is it expected that two occurrances of fc-cache run concurrently (privileged and regular startx)?

Note that above, both versions of fc-cache disagree about the number of fonts in /System/Library/Fonts and /Library/Fonts. How comes? There's no such difference about /usr/X11R6/lib/X11/fonts.

The good news is that e.g. xterm opens way before fc-cache completes.

BTW, Konsole also shows, alas without line number, 3 occurrences of
org.macosforge.xquartz.startx expr: syntax error

The Mac mini machine is almost bare bones, with very few apps installed (parts of XCode, perhaps remnants of an XQuartz from Leopard before the migration to Snow Leopard)

Thank you for your work on X11/XQuartz,
      Jörg Höhle
Comment 1 Jörg Höhle 2017-03-19 13:58:08 UTC
I now tried to run fc-cache as root, with no improvements.

# font_cache -s -v
font_cache: Scanning system font directories to generate X11 font caches
font_cache: Updating FC cache
/opt/X11/share/fonts: caching, new cache contents: 0 fonts, 10 dirs
/opt/X11/share/fonts: failed to write cache
[...]
# fc-cache -v -s
/opt/X11/share/fonts: caching, new cache contents: 0 fonts, 10 dirs
/opt/X11/share/fonts: failed to write cache
[...]
# fc-cache -v -s -r
/opt/X11/share/fonts: caching, new cache contents: 0 fonts, 10 dirs
/opt/X11/share/fonts: failed to write cache
[...]
/Library/Fonts: failed to write cache
/opt/X11/var/cache/fontconfig: not cleaning unwritable cache directory

Despite -r, none of the files named fonts.{dir,scale,alias,list} were removed from /opt/X11 or /usr/X11R6 (judging from the timestamps).

/opt/X11/var/cache/fontconfig contains 34000 *empty* files named abcdef*-le64.cache-7.TMP-UVWXYZ and a few empty CACHEDIR.TAG.TMP-JqBcKq ones all generated this week. That's quite different from the few non-empty files here:
  /Users/admin/.fontconfig:
drwxr-xr-x   9 admin  staff     306 Mar 19 14:12 .
drwxr-xr-x  64 admin  staff    2176 Mar 19 09:13 ..
-rw-r--r--   1 admin  staff     104 Feb  3  2013 0a854daaebe3a1bb80439bf071d386e2-x86-64.cache-2
-rw-r--r--   1 admin  staff     104 Feb  2  2013 0a854daaebe3a1bb80439bf071d386e2-x86-64.cache-3
-rw-r--r--   1 admin  staff     168 Mar 19 09:07 558352270fb122ca08359d23b5a778d4-x86-64.cache-2
-rw-r--r--   1 admin  staff  502648 Mar 13 23:02 84c0f976e30e948e99073af70f4ae876-x86-64.cache-2
-rw-------   1 admin  staff       0 Mar 19 09:06 CACHEDIR.TAG.TMP-9fffpw
-rw-r--r--   1 admin  staff  216992 Mar 13 23:02 b0a71e6bf6a8a1a908413a823d76e21f-x86-64.cache-2
-rw-r--r--   1 admin  staff     160 Mar 19 09:07 d48774f8c79c4ec74ba4bcd2a4c592e2-x86-64.cache-2
Comment 2 Akira TAGOH 2017-03-21 02:29:00 UTC
This might be fixed in https://cgit.freedesktop.org/fontconfig/commit/?id=0e9b2a152729bfd457e656a9258a06cbfdac1bae

Please test.
Comment 3 Jörg Höhle 2017-03-29 18:01:21 UTC
I'd like to test, however I'd appreciate a binary. Could you please provide one?
Comment 4 Akira TAGOH 2017-03-30 02:08:12 UTC
I don't have a build env to provide a binary for XQuartz.
Comment 5 GitLab Migration User 2018-08-20 21:46:15 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/45.


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.