Title: [256474] trunk/Source/WebCore
Revision
256474
Author
[email protected]
Date
2020-02-12 13:50:49 -0800 (Wed, 12 Feb 2020)

Log Message

Web Inspector: inspector/cpu-profiler/threads.html is flaky crashing
https://bugs.webkit.org/show_bug.cgi?id=207588
<rdar://problem/57458123>

Reviewed by Yusuke Suzuki.

* page/cocoa/ResourceUsageThreadCocoa.mm:
(WebCore::ResourceUsageThread::platformCollectCPUData):
Use a fence to force Thread to be completely ready for use by other threads
prior to storing it. Otherwise, ResourceUsageThread may see it too early.

* workers/WorkerThread.cpp:
(WebCore::WorkerThread::start): Ignore worker threads that are
not fully initialized.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (256473 => 256474)


--- trunk/Source/WebCore/ChangeLog	2020-02-12 21:49:12 UTC (rev 256473)
+++ trunk/Source/WebCore/ChangeLog	2020-02-12 21:50:49 UTC (rev 256474)
@@ -1,3 +1,20 @@
+2020-02-12  Brian Burg  <[email protected]>
+
+        Web Inspector: inspector/cpu-profiler/threads.html is flaky crashing
+        https://bugs.webkit.org/show_bug.cgi?id=207588
+        <rdar://problem/57458123>
+
+        Reviewed by Yusuke Suzuki.
+
+        * page/cocoa/ResourceUsageThreadCocoa.mm:
+        (WebCore::ResourceUsageThread::platformCollectCPUData):
+        Use a fence to force Thread to be completely ready for use by other threads
+        prior to storing it. Otherwise, ResourceUsageThread may see it too early.
+
+        * workers/WorkerThread.cpp:
+        (WebCore::WorkerThread::start): Ignore worker threads that are
+        not fully initialized.
+
 2020-02-12  Youenn Fablet  <[email protected]>
 
         ServiceWorkerContainer::jobResolvedWithRegistration scopeExit should capture all lambda parameters by value

Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm (256473 => 256474)


--- trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm	2020-02-12 21:49:12 UTC (rev 256473)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm	2020-02-12 21:50:49 UTC (rev 256474)
@@ -168,6 +168,9 @@
     {
         LockHolder lock(WorkerThread::workerThreadsMutex());
         for (auto* thread : WorkerThread::workerThreads(lock)) {
+            // Ignore worker threads that have not been fully started yet.
+            if (!thread->thread())
+                continue;
             mach_port_t machThread = thread->thread()->machThread();
             if (machThread != MACH_PORT_NULL)
                 knownWorkerThreads.set(machThread, thread->identifier().isolatedCopy());

Modified: trunk/Source/WebCore/workers/WorkerThread.cpp (256473 => 256474)


--- trunk/Source/WebCore/workers/WorkerThread.cpp	2020-02-12 21:49:12 UTC (rev 256473)
+++ trunk/Source/WebCore/workers/WorkerThread.cpp	2020-02-12 21:50:49 UTC (rev 256474)
@@ -142,9 +142,12 @@
 
     m_evaluateCallback = WTFMove(evaluateCallback);
 
-    m_thread = Thread::create(isServiceWorkerThread() ? "WebCore: Service Worker" : "WebCore: Worker", [this] {
+    Ref<Thread> thread = Thread::create(isServiceWorkerThread() ? "WebCore: Service Worker" : "WebCore: Worker", [this] {
         workerThread();
     });
+    // Force the Thread object to be initialized fully before storing it to m_thread (and becoming visible to other threads).
+    WTF::storeStoreFence();
+    m_thread = WTFMove(thread);
 }
 
 void WorkerThread::workerThread()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to