⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 236509 in webkit


Ignore:
Timestamp:
Sep 26, 2018, 11:20:06 AM (8 years ago)
Author:
bshafiei@apple.com
Message:

Cherry-pick r236254. rdar://problem/44182860

Fix crash under FontCache::purgeInactiveFontData() when a memory warning fires
https://bugs.webkit.org/show_bug.cgi?id=189722
rdar://problem/44182860

Reviewed by Myles C. Maxfield.

Hashing of FontPlatformData for cachedFonts() is somewhat broken because CFEqual() on CTFont
can return false when the fonts are actually the same, and have the same CFHash(). This
can result in multiple entries in cachedFonts() with the same Font.

Then in FontCache::purgeInactiveFontData(), the loop that appends fonts to fontsToDelete
gets the value by reference, and WTFMoves it into fontsToDelete. This nulls out all
the entries sharing the same value, leaving null entries in the hash table.
We later crash at font->hasOneRef() when using one of those null entries.

Fix by making a copy of the RefPtr<Font> in the loop, so the WTFMove doesn't nuke
the hash table entries. The entries will get removed at cachedFonts().remove() lower down.

  • platform/graphics/FontCache.cpp: (WebCore::FontCache::purgeInactiveFontData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236254 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
tags/Safari-607.1.7.3/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/Safari-607.1.7.3/Source/WebCore/ChangeLog

    r236268 r236509  
     12018-09-26  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r236254. rdar://problem/44182860
     4
     5    Fix crash under FontCache::purgeInactiveFontData() when a memory warning fires
     6    https://bugs.webkit.org/show_bug.cgi?id=189722
     7    rdar://problem/44182860
     8   
     9    Reviewed by Myles C. Maxfield.
     10   
     11    Hashing of FontPlatformData for cachedFonts() is somewhat broken because CFEqual() on CTFont
     12    can return false when the fonts are actually the same, and have the same CFHash(). This
     13    can result in multiple entries in cachedFonts() with the same Font.
     14   
     15    Then in FontCache::purgeInactiveFontData(), the loop that appends fonts to fontsToDelete
     16    gets the value by reference, and WTFMoves it into fontsToDelete. This nulls out all
     17    the entries sharing the same value, leaving null entries in the hash table.
     18    We later crash at font->hasOneRef() when using one of those null entries.
     19   
     20    Fix by making a copy of the RefPtr<Font> in the loop, so the WTFMove doesn't nuke
     21    the hash table entries. The entries will get removed at cachedFonts().remove() lower down.
     22   
     23    * platform/graphics/FontCache.cpp:
     24    (WebCore::FontCache::purgeInactiveFontData):
     25   
     26   
     27    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236254 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     28
     29    2018-09-20  Simon Fraser  <simon.fraser@apple.com>
     30
     31            Fix crash under FontCache::purgeInactiveFontData() when a memory warning fires
     32            https://bugs.webkit.org/show_bug.cgi?id=189722
     33            rdar://problem/44182860
     34
     35            Reviewed by Myles C. Maxfield.
     36
     37            Hashing of FontPlatformData for cachedFonts() is somewhat broken because CFEqual() on CTFont
     38            can return false when the fonts are actually the same, and have the same CFHash(). This
     39            can result in multiple entries in cachedFonts() with the same Font.
     40
     41            Then in FontCache::purgeInactiveFontData(), the loop that appends fonts to fontsToDelete
     42            gets the value by reference, and WTFMoves it into fontsToDelete. This nulls out all
     43            the entries sharing the same value, leaving null entries in the hash table.
     44            We later crash at font->hasOneRef() when using one of those null entries.
     45
     46            Fix by making a copy of the RefPtr<Font> in the loop, so the WTFMove doesn't nuke
     47            the hash table entries. The entries will get removed at cachedFonts().remove() lower down.
     48
     49            * platform/graphics/FontCache.cpp:
     50            (WebCore::FontCache::purgeInactiveFontData):
     51
    1522018-09-20  Kocsen Chung  <kocsen_chung@apple.com>
    253
  • tags/Safari-607.1.7.3/Source/WebCore/platform/graphics/FontCache.cpp

    r235862 r236509  
    377377    while (purgeCount) {
    378378        Vector<RefPtr<Font>, 20> fontsToDelete;
    379         for (auto& font : cachedFonts().values()) {
     379        for (auto font : cachedFonts().values()) {
    380380            LOG(Fonts, " trying to purge font %s (has one ref %d)", font->platformData().description().utf8().data(), font->hasOneRef());
    381381            if (!font->hasOneRef())
Note: See TracChangeset for help on using the changeset viewer.