Title: [200554] trunk/Source/WebCore
Revision
200554
Author
[email protected]
Date
2016-05-08 08:22:36 -0700 (Sun, 08 May 2016)

Log Message

ThreadSanitizer: Data race and thread leak in WebCore::ScrollingThread::createThreadIfNeeded
<https://webkit.org/b/157462>

Reviewed by Darin Adler.

Reproduced with multiple existing tests.

* page/scrolling/ScrollingThread.cpp:
(WebCore::ScrollingThread::createThreadIfNeeded): Use a
std::once_flag to initialize Scrolling Thread since this may be
called from background threads.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200553 => 200554)


--- trunk/Source/WebCore/ChangeLog	2016-05-08 07:11:12 UTC (rev 200553)
+++ trunk/Source/WebCore/ChangeLog	2016-05-08 15:22:36 UTC (rev 200554)
@@ -1,3 +1,17 @@
+2016-05-08  David Kilzer  <[email protected]>
+
+        ThreadSanitizer: Data race and thread leak in WebCore::ScrollingThread::createThreadIfNeeded
+        <https://webkit.org/b/157462>
+
+        Reviewed by Darin Adler.
+
+        Reproduced with multiple existing tests.
+
+        * page/scrolling/ScrollingThread.cpp:
+        (WebCore::ScrollingThread::createThreadIfNeeded): Use a
+        std::once_flag to initialize Scrolling Thread since this may be
+        called from background threads.
+
 2016-05-08  Darin Adler  <[email protected]>
 
         Try to fix build without rolling out that last change.

Modified: trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp (200553 => 200554)


--- trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp	2016-05-08 07:11:12 UTC (rev 200553)
+++ trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp	2016-05-08 15:22:36 UTC (rev 200554)
@@ -74,19 +74,21 @@
 
 void ScrollingThread::createThreadIfNeeded()
 {
-    if (m_threadIdentifier)
-        return;
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [&] {
+        // Wait for the thread to initialize the run loop.
+        {
+            std::unique_lock<Lock> lock(m_initializeRunLoopMutex);
 
-    // Wait for the thread to initialize the run loop.
-    {
-        std::unique_lock<Lock> lock(m_initializeRunLoopMutex);
-
-        m_threadIdentifier = createThread(threadCallback, this, "WebCore: Scrolling");
+            m_threadIdentifier = createThread(threadCallback, this, "WebCore: Scrolling");
         
 #if PLATFORM(COCOA)
-        m_initializeRunLoopConditionVariable.wait(lock, [this]{ return m_threadRunLoop; });
+            m_initializeRunLoopConditionVariable.wait(lock, [this] {
+                return m_threadRunLoop;
+            });
 #endif
-    }
+        }
+    });
 }
 
 void ScrollingThread::threadCallback(void* scrollingThread)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to