Title: [246652] trunk/Source/WebCore
Revision
246652
Author
bfulg...@apple.com
Date
2019-06-20 13:39:29 -0700 (Thu, 20 Jun 2019)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (246651 => 246652)


--- trunk/Source/WebCore/ChangeLog	2019-06-20 20:35:57 UTC (rev 246651)
+++ trunk/Source/WebCore/ChangeLog	2019-06-20 20:39:29 UTC (rev 246652)
@@ -1,3 +1,23 @@
+2019-06-20  Brent Fulgham  <bfulg...@apple.com>
+
+        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.
+
 2019-06-20  Saam Barati  <sbar...@apple.com>
 
         [WHLSL] Property resolver needs to recurse on newValueExpression for RMW operations

Modified: trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm (246651 => 246652)


--- trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm	2019-06-20 20:35:57 UTC (rev 246651)
+++ trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm	2019-06-20 20:39:29 UTC (rev 246652)
@@ -50,13 +50,13 @@
     if (!domain.isAllASCII())
         return domain;
 
-    static NeverDestroyed<HashMap<String, String, ASCIICaseInsensitiveHash>> cache;
     static Lock cacheLock;
+    auto locker = holdLock(cacheLock);
 
+    static NeverDestroyed<HashMap<String, String, ASCIICaseInsensitiveHash>> cache;
+
     auto isolatedDomain = domain.isolatedCopy();
-
-    auto locker = holdLock(cacheLock);
-
+    
     constexpr auto maximumSizeToPreventUnlimitedGrowth = 128;
     if (cache.get().size() == maximumSizeToPreventUnlimitedGrowth)
         cache.get().remove(cache.get().random());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to