Changeset 246652 in webkit


Ignore:
Timestamp:
Jun 20, 2019 1:39:29 PM (5 years ago)
Author:
Brent Fulgham
Message:

Resolve frequent crashes in topPrivatelyControlledDomain
https://bugs.webkit.org/show_bug.cgi?id=199072
<rdar://problem/51428162>

Reviewed by Youenn Fablet.

Crash data indicates that we are frequently crashing when multiple threads call
WebCore::topPrivatelyControlledDomain.

Code review showed the potential for a thread contention issue, since WebKit builds
with '--fno-threadsafe-statics'.

This patch corrects the thread safety issue in WebCore::topPrivatelyControlledDomain.

  • platform/mac/PublicSuffixMac.mm:

(WebCore::topPrivatelyControlledDomain): Only instantiate the static cache after the
current thread has achieved its lock.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r246649 r246652  
     12019-06-20  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Resolve frequent crashes in topPrivatelyControlledDomain
     4        https://bugs.webkit.org/show_bug.cgi?id=199072
     5        <rdar://problem/51428162>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        Crash data indicates that we are frequently crashing when multiple threads call
     10        WebCore::topPrivatelyControlledDomain.
     11
     12        Code review showed the potential for a thread contention issue, since WebKit builds
     13        with '--fno-threadsafe-statics'.
     14
     15        This patch corrects the thread safety issue in WebCore::topPrivatelyControlledDomain.
     16
     17        * platform/mac/PublicSuffixMac.mm:
     18        (WebCore::topPrivatelyControlledDomain): Only instantiate the static cache after the
     19        current thread has achieved its lock.
     20
    1212019-06-20  Saam Barati  <sbarati@apple.com>
    222
  • trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm

    r238771 r246652  
    5151        return domain;
    5252
     53    static Lock cacheLock;
     54    auto locker = holdLock(cacheLock);
     55
    5356    static NeverDestroyed<HashMap<String, String, ASCIICaseInsensitiveHash>> cache;
    54     static Lock cacheLock;
    5557
    5658    auto isolatedDomain = domain.isolatedCopy();
    57 
    58     auto locker = holdLock(cacheLock);
    59 
     59   
    6060    constexpr auto maximumSizeToPreventUnlimitedGrowth = 128;
    6161    if (cache.get().size() == maximumSizeToPreventUnlimitedGrowth)
Note: See TracChangeset for help on using the changeset viewer.