Changeset 248376 in webkit


Ignore:
Timestamp:
Aug 7, 2019 10:31:10 AM (5 years ago)
Author:
Chris Dumez
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:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r248373 r248376  
     12019-08-07  Chris Dumez  <cdumez@apple.com>
     2
     3        Fix thread safety issue under JSHistory::visitAdditionalChildren()
     4        https://bugs.webkit.org/show_bug.cgi?id=200504
     5
     6        Reviewed by Darin Adler.
     7
     8        JSHistory::visitAdditionalChildren() is called from a GC thread and was calling
     9        History::cachedState() whose implementation goes deep into WebCore
     10        (FrameLoader / HistoryController). Among other things, it null checks m_window
     11        which is a WeakPtr and then later dereferences it to get the Frame object, which
     12        is not safe from the non-main thread.
     13
     14        To address the issue, introduce a simpler cachedStateForGC() getter which is
     15        thread safe, and use it in JSHistory::visitAdditionalChildren().
     16
     17        * bindings/js/JSHistoryCustom.cpp:
     18        (WebCore::JSHistory::visitAdditionalChildren):
     19        * page/History.h:
     20
    1212019-08-07  Priyanka Agarwal  <pagarwal999@apple.com>
    222
  • trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp

    r244225 r248376  
    4747void JSHistory::visitAdditionalChildren(SlotVisitor& visitor)
    4848{
    49     wrapped().cachedState().visit(visitor);
     49    wrapped().cachedStateForGC().visit(visitor);
    5050}
    5151
  • trunk/Source/WebCore/page/History.h

    r243887 r248376  
    5454    SerializedScriptValue* state();
    5555    JSValueInWrappedObject& cachedState();
     56    JSValueInWrappedObject& cachedStateForGC() { return m_cachedState; }
    5657
    5758    void back();
Note: See TracChangeset for help on using the changeset viewer.