Title: [196730] trunk/Source/WebKit2
Revision
196730
Author
[email protected]
Date
2016-02-17 16:37:50 -0800 (Wed, 17 Feb 2016)

Log Message

RemoteInspector deadlocks if _WKAutomationDelegate creates/registers a target synchronously
https://bugs.webkit.org/show_bug.cgi?id=154359
<rdar://problem/24708897>

Reviewed by Joseph Pecoraro.

RemoteInspector always grabs a lock whenever receiving or sending XPC messages. If it
forwards a new session request via _WKAutomationDelegate, and the client synchronously
creates and registers a session, then RemoteInspector will try to grab the lock again
while adding the session to its registry, causing a deadlock.

* UIProcess/Cocoa/AutomationClient.mm:
(WebKit::AutomationClient::requestAutomationSession): Add a dispatch_async() to
protect clients from accidentally deadlocking. They shouldn't have to care about
RemoteInspector's locking mechanisms.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (196729 => 196730)


--- trunk/Source/WebKit2/ChangeLog	2016-02-18 00:11:21 UTC (rev 196729)
+++ trunk/Source/WebKit2/ChangeLog	2016-02-18 00:37:50 UTC (rev 196730)
@@ -1,3 +1,21 @@
+2016-02-17  Brian Burg  <[email protected]>
+
+        RemoteInspector deadlocks if _WKAutomationDelegate creates/registers a target synchronously
+        https://bugs.webkit.org/show_bug.cgi?id=154359
+        <rdar://problem/24708897>
+
+        Reviewed by Joseph Pecoraro.
+
+        RemoteInspector always grabs a lock whenever receiving or sending XPC messages. If it
+        forwards a new session request via _WKAutomationDelegate, and the client synchronously
+        creates and registers a session, then RemoteInspector will try to grab the lock again
+        while adding the session to its registry, causing a deadlock.
+
+        * UIProcess/Cocoa/AutomationClient.mm:
+        (WebKit::AutomationClient::requestAutomationSession): Add a dispatch_async() to
+        protect clients from accidentally deadlocking. They shouldn't have to care about
+        RemoteInspector's locking mechanisms.
+
 2016-02-17  Anders Carlsson  <[email protected]>
 
         Remove an unused function

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/AutomationClient.mm (196729 => 196730)


--- trunk/Source/WebKit2/UIProcess/Cocoa/AutomationClient.mm	2016-02-18 00:11:21 UTC (rev 196729)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/AutomationClient.mm	2016-02-18 00:37:50 UTC (rev 196730)
@@ -69,8 +69,13 @@
 
 void AutomationClient::requestAutomationSession(const String& sessionIdentifier)
 {
-    if (m_delegateMethods.requestAutomationSession)
-        [m_delegate.get() _processPool:m_processPool didRequestAutomationSessionWithIdentifier:sessionIdentifier];
+    // Force clients to create and register a session asynchronously. Otherwise,
+    // RemoteInspector will try to acquire its lock to register the new session and
+    // deadlock because it's already taken while handling XPC messages.
+    dispatch_async(dispatch_get_main_queue(), ^{
+        if (m_delegateMethods.requestAutomationSession)
+            [m_delegate.get() _processPool:m_processPool didRequestAutomationSessionWithIdentifier:sessionIdentifier];
+    });
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to