Title: [241894] branches/safari-607-branch/Source/WebCore
Revision
241894
Author
[email protected]
Date
2019-02-21 13:27:39 -0800 (Thu, 21 Feb 2019)

Log Message

Cherry-pick r241848. rdar://problem/48257838

    Crash in DOMWindowExtension::suspendForPageCache
    https://bugs.webkit.org/show_bug.cgi?id=194871

    Reviewed by Chris Dumez.

    This is a speculative fix for a crash in DOMWindowExtension::suspendForPageCache.

    We think it's possible for DOMWindowExtension::suspendForPageCache notifying the clients via
    dispatchWillDisconnectDOMWindowExtensionFromGlobalObject to remove other DOMWindowExtension's.
    Check that each DOMWindowProperty is still in m_properties before invoking suspendForPageCache
    to avoid the crash.

    * page/DOMWindow.cpp:
    (WebCore::DOMWindow::willDestroyCachedFrame):
    (WebCore::DOMWindow::willDestroyDocumentInFrame):
    (WebCore::DOMWindow::willDetachDocumentFromFrame):
    (WebCore::DOMWindow::suspendForPageCache):
    (WebCore::DOMWindow::resumeFromPageCache):
    * page/DOMWindowExtension.cpp:
    (WebCore::DOMWindowExtension::suspendForPageCache):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241848 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (241893 => 241894)


--- branches/safari-607-branch/Source/WebCore/ChangeLog	2019-02-21 21:27:36 UTC (rev 241893)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog	2019-02-21 21:27:39 UTC (rev 241894)
@@ -1,5 +1,56 @@
 2019-02-20  Alan Coon  <[email protected]>
 
+        Cherry-pick r241848. rdar://problem/48257838
+
+    Crash in DOMWindowExtension::suspendForPageCache
+    https://bugs.webkit.org/show_bug.cgi?id=194871
+    
+    Reviewed by Chris Dumez.
+    
+    This is a speculative fix for a crash in DOMWindowExtension::suspendForPageCache.
+    
+    We think it's possible for DOMWindowExtension::suspendForPageCache notifying the clients via
+    dispatchWillDisconnectDOMWindowExtensionFromGlobalObject to remove other DOMWindowExtension's.
+    Check that each DOMWindowProperty is still in m_properties before invoking suspendForPageCache
+    to avoid the crash.
+    
+    * page/DOMWindow.cpp:
+    (WebCore::DOMWindow::willDestroyCachedFrame):
+    (WebCore::DOMWindow::willDestroyDocumentInFrame):
+    (WebCore::DOMWindow::willDetachDocumentFromFrame):
+    (WebCore::DOMWindow::suspendForPageCache):
+    (WebCore::DOMWindow::resumeFromPageCache):
+    * page/DOMWindowExtension.cpp:
+    (WebCore::DOMWindowExtension::suspendForPageCache):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241848 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-02-20  Ryosuke Niwa  <[email protected]>
+
+            Crash in DOMWindowExtension::suspendForPageCache
+            https://bugs.webkit.org/show_bug.cgi?id=194871
+
+            Reviewed by Chris Dumez.
+
+            This is a speculative fix for a crash in DOMWindowExtension::suspendForPageCache.
+
+            We think it's possible for DOMWindowExtension::suspendForPageCache notifying the clients via
+            dispatchWillDisconnectDOMWindowExtensionFromGlobalObject to remove other DOMWindowExtension's.
+            Check that each DOMWindowProperty is still in m_properties before invoking suspendForPageCache
+            to avoid the crash.
+
+            * page/DOMWindow.cpp:
+            (WebCore::DOMWindow::willDestroyCachedFrame):
+            (WebCore::DOMWindow::willDestroyDocumentInFrame):
+            (WebCore::DOMWindow::willDetachDocumentFromFrame):
+            (WebCore::DOMWindow::suspendForPageCache):
+            (WebCore::DOMWindow::resumeFromPageCache):
+            * page/DOMWindowExtension.cpp:
+            (WebCore::DOMWindowExtension::suspendForPageCache):
+
+2019-02-20  Alan Coon  <[email protected]>
+
         Cherry-pick r241788. rdar://problem/48248202
 
     REGRESSION (r238090): Toggling visibility on the <html> element can result in a blank web view

Modified: branches/safari-607-branch/Source/WebCore/page/DOMWindow.cpp (241893 => 241894)


--- branches/safari-607-branch/Source/WebCore/page/DOMWindow.cpp	2019-02-21 21:27:36 UTC (rev 241893)
+++ branches/safari-607-branch/Source/WebCore/page/DOMWindow.cpp	2019-02-21 21:27:39 UTC (rev 241894)
@@ -456,8 +456,10 @@
 {
     // It is necessary to copy m_properties to a separate vector because the DOMWindowProperties may
     // unregister themselves from the DOMWindow as a result of the call to willDestroyGlobalObjectInCachedFrame.
-    for (auto& property : copyToVector(m_properties))
-        property->willDestroyGlobalObjectInCachedFrame();
+    for (auto* property : copyToVector(m_properties)) {
+        if (m_properties.contains(property))
+            property->willDestroyGlobalObjectInCachedFrame();
+    }
 }
 
 void DOMWindow::willDestroyDocumentInFrame()
@@ -464,8 +466,10 @@
 {
     // It is necessary to copy m_properties to a separate vector because the DOMWindowProperties may
     // unregister themselves from the DOMWindow as a result of the call to willDestroyGlobalObjectInFrame.
-    for (auto& property : copyToVector(m_properties))
-        property->willDestroyGlobalObjectInFrame();
+    for (auto* property : copyToVector(m_properties)) {
+        if (m_properties.contains(property))
+            property->willDestroyGlobalObjectInFrame();
+    }
 }
 
 void DOMWindow::willDetachDocumentFromFrame()
@@ -475,8 +479,10 @@
 
     // It is necessary to copy m_properties to a separate vector because the DOMWindowProperties may
     // unregister themselves from the DOMWindow as a result of the call to willDetachGlobalObjectFromFrame.
-    for (auto& property : copyToVector(m_properties))
-        property->willDetachGlobalObjectFromFrame();
+    for (auto& property : copyToVector(m_properties)) {
+        if (m_properties.contains(property))
+            property->willDetachGlobalObjectFromFrame();
+    }
 
     if (m_performance)
         m_performance->clearResourceTimings();
@@ -520,8 +526,10 @@
 
 void DOMWindow::suspendForPageCache()
 {
-    for (auto& property : copyToVector(m_properties))
-        property->suspendForPageCache();
+    for (auto* property : copyToVector(m_properties)) {
+        if (m_properties.contains(property))
+            property->suspendForPageCache();
+    }
 
     m_suspendedForDocumentSuspension = true;
 }
@@ -528,8 +536,10 @@
 
 void DOMWindow::resumeFromPageCache()
 {
-    for (auto& property : copyToVector(m_properties))
-        property->resumeFromPageCache();
+    for (auto* property : copyToVector(m_properties)) {
+        if (m_properties.contains(property))
+            property->resumeFromPageCache();
+    }
 
     m_suspendedForDocumentSuspension = false;
 }

Modified: branches/safari-607-branch/Source/WebCore/page/DOMWindowExtension.cpp (241893 => 241894)


--- branches/safari-607-branch/Source/WebCore/page/DOMWindowExtension.cpp	2019-02-21 21:27:36 UTC (rev 241893)
+++ branches/safari-607-branch/Source/WebCore/page/DOMWindowExtension.cpp	2019-02-21 21:27:39 UTC (rev 241894)
@@ -48,11 +48,11 @@
     // Calling out to the client might result in this DOMWindowExtension being destroyed
     // while there is still work to do.
     Ref<DOMWindowExtension> protectedThis(*this);
-    
-    Frame* frame = this->frame();
+
+    auto frame = makeRef(*this->frame());
     frame->loader().client().dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(this);
 
-    m_disconnectedFrame = frame;
+    m_disconnectedFrame = WTFMove(frame);
 
     DOMWindowProperty::suspendForPageCache();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to