Title: [223101] branches/safari-604-branch/Source/WebCore
Revision
223101
Author
[email protected]
Date
2017-10-09 17:08:19 -0700 (Mon, 09 Oct 2017)

Log Message

Apply patch. rdar://problem/34770842

    Cherry-pick r221083. rdar://problem/34770842, rdar://problem/34770849

Modified Paths

Diff

Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (223100 => 223101)


--- branches/safari-604-branch/Source/WebCore/ChangeLog	2017-10-10 00:08:16 UTC (rev 223100)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog	2017-10-10 00:08:19 UTC (rev 223101)
@@ -1,5 +1,34 @@
 2017-10-02  Jason Marcell  <[email protected]>
 
+        Apply patch. rdar://problem/34770842
+
+    Cherry-pick r221083. rdar://problem/34770842, rdar://problem/34770849
+
+    2017-10-02  Mark Lam  <[email protected]>
+
+            Cherry-pick r221083. rdar://problem/34770842, rdar://problem/34770849
+
+        2017-08-23  Yusuke Suzuki  <[email protected]>
+
+                Race condition in StartWebThread causing crash
+                https://bugs.webkit.org/show_bug.cgi?id=175852
+
+                Reviewed by Mark Lam.
+
+                When starting web thread, the main thread waits for completion of web thread initialization
+                by using pthread_cond_t. However, the main thread may be woken up due to the existence of
+                the spurious wake up of pthread_cond_t.
+
+                Instead, we should use WTF::Lock and WTF::Condition. Since our StartWebThread already calls
+                WTF::initializeThreading, it is safe to use WTF::Lock and WTF::Condition. And our WTF::Condition
+                does not have the spurious wake up problem as described in Condition.h.
+
+                * platform/ios/wak/WebCoreThread.mm:
+                (RunWebThread):
+                (StartWebThread):
+
+2017-10-02  Jason Marcell  <[email protected]>
+
         Cherry-pick r222190. rdar://problem/34771470
 
     2017-09-18  Tim Horton  <[email protected]>

Modified: branches/safari-604-branch/Source/WebCore/platform/ios/wak/WebCoreThread.mm (223100 => 223101)


--- branches/safari-604-branch/Source/WebCore/platform/ios/wak/WebCoreThread.mm	2017-10-10 00:08:16 UTC (rev 223100)
+++ branches/safari-604-branch/Source/WebCore/platform/ios/wak/WebCoreThread.mm	2017-10-10 00:08:19 UTC (rev 223101)
@@ -127,8 +127,8 @@
 
 static CFRunLoopObserverRef mainRunLoopAutoUnlockObserver;
 
-static pthread_mutex_t startupLock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t startupCondition = PTHREAD_COND_INITIALIZER;
+static StaticLock startupLock;
+static StaticCondition startupCondition;
 
 static WebThreadContext *webThreadContext;
 static pthread_key_t threadContextKey;
@@ -681,15 +681,11 @@
     WebThreadReleaseSource = CFRunLoopSourceCreate(NULL, -1, &ReleaseSourceContext);
     CFRunLoopAddSource(webThreadRunLoop, WebThreadReleaseSource, kCFRunLoopDefaultMode);
 
-    int result = pthread_mutex_lock(&startupLock);
-    ASSERT_WITH_MESSAGE(result == 0, "startup lock failed with code:%d", result);
+    {
+        LockHolder locker(startupLock);
+        startupCondition.notifyOne();
+    }
 
-    result = pthread_cond_signal(&startupCondition);
-    ASSERT_WITH_MESSAGE(result == 0, "startup signal failed with code:%d", result);
-
-    result = pthread_mutex_unlock(&startupLock);
-    ASSERT_WITH_MESSAGE(result == 0, "startup unlock failed with code:%d", result);
-
     while (1)
         CFRunLoopRunInMode(kCFRunLoopDefaultMode, DistantFuture, true);
 
@@ -702,6 +698,9 @@
 {
     webThreadStarted = TRUE;
 
+    // ThreadGlobalData touches AtomicString, which requires Threading initialization.
+    WTF::initializeThreading();
+
     // Initialize ThreadGlobalData on the main UI thread so that the WebCore thread
     // can later set it's thread-specific data to point to the same objects.
     WebCore::ThreadGlobalData& unused = WebCore::threadGlobalData();
@@ -755,21 +754,18 @@
     pthread_attr_setschedparam(&tattr, &param);
 
     // Wait for the web thread to startup completely before we continue.
-    int result = pthread_mutex_lock(&startupLock);
-    ASSERT_WITH_MESSAGE(result == 0, "startup lock failed with code:%d", result);
+    {
+        LockHolder locker(startupLock);
 
-    // Propagate the mainThread's fenv to workers & the web thread.
-    FloatingPointEnvironment::singleton().saveMainThreadEnvironment();
+        // Propagate the mainThread's fenv to workers & the web thread.
+        FloatingPointEnvironment::singleton().saveMainThreadEnvironment();
 
-    pthread_create(&webThread, &tattr, RunWebThread, NULL);
-    pthread_attr_destroy(&tattr);
+        pthread_create(&webThread, &tattr, RunWebThread, NULL);
+        pthread_attr_destroy(&tattr);
 
-    result = pthread_cond_wait(&startupCondition, &startupLock);
-    ASSERT_WITH_MESSAGE(result == 0, "startup wait failed with code:%d", result);
+        startupCondition.wait(startupLock);
+    }
 
-    result = pthread_mutex_unlock(&startupLock);
-    ASSERT_WITH_MESSAGE(result == 0, "startup unlock failed with code:%d", result);
-
     initializeApplicationUIThreadIdentifier();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to