Title: [248376] trunk/Source/WebCore
Revision
248376
Author
[email protected]
Date
2019-08-07 10:31:10 -0700 (Wed, 07 Aug 2019)

Log Message

Fix thread safety issue under JSHistory::visitAdditionalChildren()
https://bugs.webkit.org/show_bug.cgi?id=200504

Reviewed by Darin Adler.

JSHistory::visitAdditionalChildren() is called from a GC thread and was calling
History::cachedState() whose implementation goes deep into WebCore
(FrameLoader / HistoryController). Among other things, it null checks m_window
which is a WeakPtr and then later dereferences it to get the Frame object, which
is not safe from the non-main thread.

To address the issue, introduce a simpler cachedStateForGC() getter which is
thread safe, and use it in JSHistory::visitAdditionalChildren().

* bindings/js/JSHistoryCustom.cpp:
(WebCore::JSHistory::visitAdditionalChildren):
* page/History.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (248375 => 248376)


--- trunk/Source/WebCore/ChangeLog	2019-08-07 17:25:37 UTC (rev 248375)
+++ trunk/Source/WebCore/ChangeLog	2019-08-07 17:31:10 UTC (rev 248376)
@@ -1,3 +1,23 @@
+2019-08-07  Chris Dumez  <[email protected]>
+
+        Fix thread safety issue under JSHistory::visitAdditionalChildren()
+        https://bugs.webkit.org/show_bug.cgi?id=200504
+
+        Reviewed by Darin Adler.
+
+        JSHistory::visitAdditionalChildren() is called from a GC thread and was calling
+        History::cachedState() whose implementation goes deep into WebCore
+        (FrameLoader / HistoryController). Among other things, it null checks m_window
+        which is a WeakPtr and then later dereferences it to get the Frame object, which
+        is not safe from the non-main thread.
+
+        To address the issue, introduce a simpler cachedStateForGC() getter which is
+        thread safe, and use it in JSHistory::visitAdditionalChildren().
+
+        * bindings/js/JSHistoryCustom.cpp:
+        (WebCore::JSHistory::visitAdditionalChildren):
+        * page/History.h:
+
 2019-08-07  Priyanka Agarwal  <[email protected]>
 
         Allow clients to toggle a text input field between being viewable and having characters hidden while maintaining 

Modified: trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp (248375 => 248376)


--- trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp	2019-08-07 17:25:37 UTC (rev 248375)
+++ trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp	2019-08-07 17:31:10 UTC (rev 248376)
@@ -46,7 +46,7 @@
 
 void JSHistory::visitAdditionalChildren(SlotVisitor& visitor)
 {
-    wrapped().cachedState().visit(visitor);
+    wrapped().cachedStateForGC().visit(visitor);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/History.h (248375 => 248376)


--- trunk/Source/WebCore/page/History.h	2019-08-07 17:25:37 UTC (rev 248375)
+++ trunk/Source/WebCore/page/History.h	2019-08-07 17:31:10 UTC (rev 248376)
@@ -53,6 +53,7 @@
 
     SerializedScriptValue* state();
     JSValueInWrappedObject& cachedState();
+    JSValueInWrappedObject& cachedStateForGC() { return m_cachedState; }
 
     void back();
     void forward();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to