Title: [277183] branches/safari-611-branch/Source/WebKit
- Revision
- 277183
- Author
- [email protected]
- Date
- 2021-05-07 11:47:55 -0700 (Fri, 07 May 2021)
Log Message
Cherry-pick r277114. rdar://problem/77638135
Fix crash when WebsiteDataStore is destroyed with outstanding getNetworkProcessConnection request
https://bugs.webkit.org/show_bug.cgi?id=225478
<rdar://77576148>
Reviewed by Chris Dumez.
In WebsiteDataStore::getNetworkProcessConnection if we don't get a connection the first time, we terminate the network process
and try again. This greatly increases our success rate. However, if we are cancelling the reply because of the destruction
of the WebsiteDataStore, we will end up doing bad things with partially destroyed objects, which ends up crashing.
In order to prevent this, use RunLoop::main.dispatch to retry on the next runloop iteration so that we will never be inside the
stack of WebsiteDataStore::~WebsiteDataStore when retrying. In that case, we will find that weakThis is null and send an empty
reply.
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::getNetworkProcessConnection):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277114 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (277182 => 277183)
--- branches/safari-611-branch/Source/WebKit/ChangeLog 2021-05-07 18:47:51 UTC (rev 277182)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog 2021-05-07 18:47:55 UTC (rev 277183)
@@ -1,5 +1,47 @@
2021-05-06 Russell Epstein <[email protected]>
+ Cherry-pick r277114. rdar://problem/77638135
+
+ Fix crash when WebsiteDataStore is destroyed with outstanding getNetworkProcessConnection request
+ https://bugs.webkit.org/show_bug.cgi?id=225478
+ <rdar://77576148>
+
+ Reviewed by Chris Dumez.
+
+ In WebsiteDataStore::getNetworkProcessConnection if we don't get a connection the first time, we terminate the network process
+ and try again. This greatly increases our success rate. However, if we are cancelling the reply because of the destruction
+ of the WebsiteDataStore, we will end up doing bad things with partially destroyed objects, which ends up crashing.
+ In order to prevent this, use RunLoop::main.dispatch to retry on the next runloop iteration so that we will never be inside the
+ stack of WebsiteDataStore::~WebsiteDataStore when retrying. In that case, we will find that weakThis is null and send an empty
+ reply.
+
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::getNetworkProcessConnection):
+
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277114 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-05-06 Alex Christensen <[email protected]>
+
+ Fix crash when WebsiteDataStore is destroyed with outstanding getNetworkProcessConnection request
+ https://bugs.webkit.org/show_bug.cgi?id=225478
+ <rdar://77576148>
+
+ Reviewed by Chris Dumez.
+
+ In WebsiteDataStore::getNetworkProcessConnection if we don't get a connection the first time, we terminate the network process
+ and try again. This greatly increases our success rate. However, if we are cancelling the reply because of the destruction
+ of the WebsiteDataStore, we will end up doing bad things with partially destroyed objects, which ends up crashing.
+ In order to prevent this, use RunLoop::main.dispatch to retry on the next runloop iteration so that we will never be inside the
+ stack of WebsiteDataStore::~WebsiteDataStore when retrying. In that case, we will find that weakThis is null and send an empty
+ reply.
+
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::getNetworkProcessConnection):
+
+2021-05-06 Russell Epstein <[email protected]>
+
Cherry-pick r276671. rdar://problem/77620763
HashTableConstIterator's consistency assertion fails while closing m_webIDBServers in NetworkProcess::didClose since r275846
Modified: branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (277182 => 277183)
--- branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-05-07 18:47:51 UTC (rev 277182)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-05-07 18:47:55 UTC (rev 277183)
@@ -1917,11 +1917,17 @@
void WebsiteDataStore::getNetworkProcessConnection(WebProcessProxy& webProcessProxy, CompletionHandler<void(const NetworkProcessConnectionInfo&)>&& reply)
{
- networkProcess().getNetworkProcessConnection(webProcessProxy, [this, weakThis = makeWeakPtr(*this), webProcessProxy = makeWeakPtr(webProcessProxy), reply = WTFMove(reply)] (auto& connectionInfo) mutable {
- if (UNLIKELY(!IPC::Connection::identifierIsValid(connectionInfo.identifier()) && webProcessProxy && weakThis)) {
- terminateNetworkProcess();
- RELEASE_LOG_IF(isPersistent(), Process, "getNetworkProcessConnection: Failed first attempt, retrying");
- networkProcess().getNetworkProcessConnection(*webProcessProxy, WTFMove(reply));
+ networkProcess().getNetworkProcessConnection(webProcessProxy, [weakThis = makeWeakPtr(*this), webProcessProxy = makeWeakPtr(webProcessProxy), reply = WTFMove(reply)] (auto& connectionInfo) mutable {
+ if (UNLIKELY(!IPC::Connection::identifierIsValid(connectionInfo.identifier()))) {
+ // Retry on the next RunLoop iteration because we may be inside the WebsiteDataStore destructor.
+ RunLoop::main().dispatch([weakThis = WTFMove(weakThis), webProcessProxy = WTFMove(webProcessProxy), reply = WTFMove(reply)] () mutable {
+ if (RefPtr<WebsiteDataStore> strongThis = weakThis.get(); strongThis && webProcessProxy) {
+ strongThis->terminateNetworkProcess();
+ RELEASE_LOG_IF(strongThis->isPersistent(), Process, "getNetworkProcessConnection: Failed first attempt, retrying");
+ strongThis->networkProcess().getNetworkProcessConnection(*webProcessProxy, WTFMove(reply));
+ } else
+ reply({ });
+ });
return;
}
reply(connectionInfo);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes