From 728bab0a1e8010ec5055ac3bdf3dc5a9f4736ae0 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Mon, 23 Mar 2020 14:23:41 +0900 Subject: [PATCH] Fix assertion in FcCacheFini() again. Resolves: rhbz#1815684 --- fontconfig-fix-assertion.patch | 72 ++++++++++++++++++++++++++++++++++ fontconfig.spec | 6 ++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/fontconfig-fix-assertion.patch b/fontconfig-fix-assertion.patch index 6bdb379..2e33736 100644 --- a/fontconfig-fix-assertion.patch +++ b/fontconfig-fix-assertion.patch @@ -70,3 +70,75 @@ index 6f82ebd..0e1421e 100644 -- 2.24.1 +From 6f6b39780215714386606ca1c5457a7106639ff4 Mon Sep 17 00:00:00 2001 +From: Akira TAGOH +Date: Mon, 23 Mar 2020 14:03:47 +0900 +Subject: [PATCH] Fix assertion in FcCacheFini() again + +The previous fix in fbc05949ef52c8a8d69233eed77f6636dffec280 was wrong. reverting. + +When reading older caches, FcDirCacheMapHelper() returns FcFalse and +it became the return value from FcDirCacheProcess() too, which is wrong. +Actually one of calls for FcDirCacheMapHelper() should be successfully +finished and closure should have a valid pointer for cache. + +Due to this, the proper finalization process wasn't running against +cache in closure. + +Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/227 +--- + src/fccache.c | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/src/fccache.c b/src/fccache.c +index 035458e..2d398c7 100644 +--- a/src/fccache.c ++++ b/src/fccache.c +@@ -365,6 +365,7 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir, + struct stat file_stat, dir_stat; + FcBool ret = FcFalse; + const FcChar8 *sysroot = FcConfigGetSysRoot (config); ++ struct timeval latest_mtime = (struct timeval){ 0 }; + + if (sysroot) + d = FcStrBuildFilename (sysroot, dir, NULL); +@@ -389,7 +390,6 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir, + #ifndef _WIN32 + FcBool retried = FcFalse; + #endif +- struct timeval latest_mtime = (struct timeval){ 0 }; + + if (sysroot) + cache_hashed = FcStrBuildFilename (sysroot, cache_dir, cache_base, NULL); +@@ -445,6 +445,8 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir, + } + FcStrListDone (list); + ++ if (closure) ++ return !!(*((FcCache **)closure) != NULL); + return ret; + } + +@@ -792,7 +794,18 @@ FcCacheFini (void) + int i; + + for (i = 0; i < FC_CACHE_MAX_LEVEL; i++) +- assert (fcCacheChains[i] == NULL); ++ { ++ if (FcDebug() & FC_DBG_CACHE) ++ { ++ if (fcCacheChains[i] != NULL) ++ { ++ FcCacheSkip *s = fcCacheChains[i]; ++ printf("Fontconfig error: not freed %p (dir: %s, refcount %d)\n", s->cache, FcCacheDir(s->cache), s->ref.count); ++ } ++ } ++ else ++ assert (fcCacheChains[i] == NULL); ++ } + assert (fcCacheMaxLevel == 0); + + free_lock (); +-- +2.24.1 + diff --git a/fontconfig.spec b/fontconfig.spec index ea61268..3dfc0af 100644 --- a/fontconfig.spec +++ b/fontconfig.spec @@ -5,7 +5,7 @@ Summary: Font configuration and customization library Name: fontconfig Version: 2.13.92 -Release: 7%{?dist} +Release: 8%{?dist} # src/ftglue.[ch] is in Public Domain # src/fccache.c contains Public Domain code # fc-case/CaseFolding.txt is in the UCD @@ -169,6 +169,10 @@ HOME=/root /usr/bin/fc-cache -s %doc fontconfig-devel.txt fontconfig-devel %changelog +* Mon Mar 23 2020 Akira TAGOH - 2.13.92-8 +- Fix assertion in FcCacheFini() again. + Resolves: rhbz#1815684 + * Wed Feb 26 2020 Akira TAGOH - 2.13.92-7 - Fix assertion in FcCacheFini().