Title: [193457] branches/safari-601.1.46-branch/Source/_javascript_Core
Revision
193457
Author
[email protected]
Date
2015-12-04 12:54:12 -0800 (Fri, 04 Dec 2015)

Log Message

Merge r188976. rdar://problem/23581597

Modified Paths

Diff

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/ChangeLog (193456 => 193457)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/ChangeLog	2015-12-04 20:54:02 UTC (rev 193456)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/ChangeLog	2015-12-04 20:54:12 UTC (rev 193457)
@@ -1,3 +1,23 @@
+2015-12-04  Timothy Hatcher  <[email protected]>
+
+        Merge r188976. rdar://problem/23581597
+
+    2015-08-26  Brian Burg  <[email protected]>
+
+            Web Inspector: REGRESSION(r188965): BackendDispatcher loses request ids when called re-entrantly
+            https://bugs.webkit.org/show_bug.cgi?id=148480
+
+            Reviewed by Joseph Pecoraro.
+
+            I added an assertion that m_currentRequestId is Nullopt when dispatch() is called, but this should
+            not hold if dispatching a backend command while debugger is paused. I will remove the assertion
+            and add proper scoping for all dispatch() branches.
+
+            No new tests, this wrong assert caused inspector/dom-debugger/node-removed.html to crash reliably.
+
+            * inspector/InspectorBackendDispatcher.cpp:
+            (Inspector::BackendDispatcher::dispatch): Cover each exit with an appropriate TemporaryChange scope.
+
 2015-12-02  Timothy Hatcher  <[email protected]>
 
         Merge r188965. rdar://problem/23581597

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/InspectorBackendDispatcher.cpp (193456 => 193457)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/InspectorBackendDispatcher.cpp	2015-12-04 20:54:02 UTC (rev 193456)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/InspectorBackendDispatcher.cpp	2015-12-04 20:54:12 UTC (rev 193457)
@@ -86,72 +86,81 @@
 
     ASSERT(!m_protocolErrors.size());
 
-    RefPtr<InspectorValue> parsedMessage;
-    if (!InspectorValue::parseJSON(message, parsedMessage)) {
-        reportProtocolError(ParseError, ASCIILiteral("Message must be in JSON format"));
-        sendPendingErrors();
-        return;
-    }
-
+    long requestId = 0;
     RefPtr<InspectorObject> messageObject;
-    if (!parsedMessage->asObject(messageObject)) {
-        reportProtocolError(InvalidRequest, ASCIILiteral("Message must be a JSONified object"));
-        sendPendingErrors();
-        return;
-    }
 
-    RefPtr<InspectorValue> requestIdValue;
-    if (!messageObject->getValue(ASCIILiteral("id"), requestIdValue)) {
-        reportProtocolError(InvalidRequest, ASCIILiteral("'id' property was not found"));
-        sendPendingErrors();
-        return;
-    }
+    {
+        // In case this is a re-entrant call from a nested run loop, we don't want to lose
+        // the outer request's id just because the inner request is bogus.
+        TemporaryChange<Optional<long>> scopedRequestId(m_currentRequestId, Nullopt);
 
-    long requestId = 0;
-    if (!requestIdValue->asInteger(requestId)) {
-        reportProtocolError(InvalidRequest, ASCIILiteral("The type of 'id' property must be integer"));
-        sendPendingErrors();
-        return;
-    }
+        RefPtr<InspectorValue> parsedMessage;
+        if (!InspectorValue::parseJSON(message, parsedMessage)) {
+            reportProtocolError(ParseError, ASCIILiteral("Message must be in JSON format"));
+            sendPendingErrors();
+            return;
+        }
 
-    ASSERT(!m_currentRequestId);
-    TemporaryChange<Optional<long>> scopedRequestId(m_currentRequestId, requestId);
+        if (!parsedMessage->asObject(messageObject)) {
+            reportProtocolError(InvalidRequest, ASCIILiteral("Message must be a JSONified object"));
+            sendPendingErrors();
+            return;
+        }
 
-    RefPtr<InspectorValue> methodValue;
-    if (!messageObject->getValue(ASCIILiteral("method"), methodValue)) {
-        reportProtocolError(InvalidRequest, ASCIILiteral("'method' property wasn't found"));
-        sendPendingErrors();
-        return;
-    }
+        RefPtr<InspectorValue> requestIdValue;
+        if (!messageObject->getValue(ASCIILiteral("id"), requestIdValue)) {
+            reportProtocolError(InvalidRequest, ASCIILiteral("'id' property was not found"));
+            sendPendingErrors();
+            return;
+        }
 
-    String methodString;
-    if (!methodValue->asString(methodString)) {
-        reportProtocolError(InvalidRequest, ASCIILiteral("The type of 'method' property must be string"));
-        sendPendingErrors();
-        return;
+        if (!requestIdValue->asInteger(requestId)) {
+            reportProtocolError(InvalidRequest, ASCIILiteral("The type of 'id' property must be integer"));
+            sendPendingErrors();
+            return;
+        }
     }
 
-    Vector<String> domainAndMethod;
-    methodString.split('.', true, domainAndMethod);
-    if (domainAndMethod.size() != 2 || !domainAndMethod[0].length() || !domainAndMethod[1].length()) {
-        reportProtocolError(InvalidRequest, ASCIILiteral("The 'method' property was formatted incorrectly. It should be 'Domain.method'"));
-        sendPendingErrors();
-        return;
-    }
+    {
+        // We could be called re-entrantly from a nested run loop, so restore the previous id.
+        TemporaryChange<Optional<long>> scopedRequestId(m_currentRequestId, requestId);
 
-    String domain = domainAndMethod[0];
-    SupplementalBackendDispatcher* domainDispatcher = m_dispatchers.get(domain);
-    if (!domainDispatcher) {
-        reportProtocolError(MethodNotFound, "'" + domain + "' domain was not found");
-        sendPendingErrors();
-        return;
-    }
+        RefPtr<InspectorValue> methodValue;
+        if (!messageObject->getValue(ASCIILiteral("method"), methodValue)) {
+            reportProtocolError(InvalidRequest, ASCIILiteral("'method' property wasn't found"));
+            sendPendingErrors();
+            return;
+        }
 
-    String method = domainAndMethod[1];
-    domainDispatcher->dispatch(requestId, method, messageObject.releaseNonNull());
+        String methodString;
+        if (!methodValue->asString(methodString)) {
+            reportProtocolError(InvalidRequest, ASCIILiteral("The type of 'method' property must be string"));
+            sendPendingErrors();
+            return;
+        }
 
-    if (m_protocolErrors.size())
-        sendPendingErrors();
+        Vector<String> domainAndMethod;
+        methodString.split('.', true, domainAndMethod);
+        if (domainAndMethod.size() != 2 || !domainAndMethod[0].length() || !domainAndMethod[1].length()) {
+            reportProtocolError(InvalidRequest, ASCIILiteral("The 'method' property was formatted incorrectly. It should be 'Domain.method'"));
+            sendPendingErrors();
+            return;
+        }
+
+        String domain = domainAndMethod[0];
+        SupplementalBackendDispatcher* domainDispatcher = m_dispatchers.get(domain);
+        if (!domainDispatcher) {
+            reportProtocolError(MethodNotFound, "'" + domain + "' domain was not found");
+            sendPendingErrors();
+            return;
+        }
+
+        String method = domainAndMethod[1];
+        domainDispatcher->dispatch(requestId, method, messageObject.releaseNonNull());
+
+        if (m_protocolErrors.size())
+            sendPendingErrors();
+    }
 }
 
 void BackendDispatcher::sendResponse(long requestId, RefPtr<InspectorObject>&& result)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to