Changeset 205033 in webkit


Ignore:
Timestamp:
Aug 26, 2016, 1:22:21 PM (9 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: HeapProfiler/ScriptProfiler do not destruct safely when JSContext is destroyed
https://bugs.webkit.org/show_bug.cgi?id=161027
<rdar://problem/27871349>

Reviewed by Mark Lam.

For JSContext inspection, when a frontend connects keep the target alive.
This means ref'ing the JSGlobalObject / VM when the first frontend
connects and deref'ing when the last frontend disconnects.

  • inspector/JSGlobalObjectInspectorController.h:
  • inspector/JSGlobalObjectInspectorController.cpp:

(Inspector::JSGlobalObjectInspectorController::globalObjectDestroyed):
(Inspector::JSGlobalObjectInspectorController::disconnectAllFrontends): Deleted.
Now that frontends keep the global object alive, when the global object
is destroyed that must mean that no frontends exist. Remove the now
stale code path.

(Inspector::JSGlobalObjectInspectorController::connectFrontend):
(Inspector::JSGlobalObjectInspectorController::disconnectFrontend):
Ref the target when the first frontend connects, deref when the last disconnects.

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r205027 r205033  
     12016-08-26  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: HeapProfiler/ScriptProfiler do not destruct safely when JSContext is destroyed
     4        https://bugs.webkit.org/show_bug.cgi?id=161027
     5        <rdar://problem/27871349>
     6
     7        Reviewed by Mark Lam.
     8
     9        For JSContext inspection, when a frontend connects keep the target alive.
     10        This means ref'ing the JSGlobalObject / VM when the first frontend
     11        connects and deref'ing when the last frontend disconnects.
     12
     13        * inspector/JSGlobalObjectInspectorController.h:
     14        * inspector/JSGlobalObjectInspectorController.cpp:
     15        (Inspector::JSGlobalObjectInspectorController::globalObjectDestroyed):
     16        (Inspector::JSGlobalObjectInspectorController::disconnectAllFrontends): Deleted.
     17        Now that frontends keep the global object alive, when the global object
     18        is destroyed that must mean that no frontends exist. Remove the now
     19        stale code path.
     20
     21        (Inspector::JSGlobalObjectInspectorController::connectFrontend):
     22        (Inspector::JSGlobalObjectInspectorController::disconnectFrontend):
     23        Ref the target when the first frontend connects, deref when the last disconnects.
     24
    1252016-08-26  Yusuke Suzuki  <utatane.tea@gmail.com>
    226
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp

    r204912 r205033  
    116116void JSGlobalObjectInspectorController::globalObjectDestroyed()
    117117{
    118     disconnectAllFrontends();
     118    ASSERT(!m_frontendRouter->hasFrontends());
    119119
    120120    m_injectedScriptManager->disconnect();
     
    132132    if (!connectedFirstFrontend)
    133133        return;
     134
     135    // Keep the JSGlobalObject and VM alive while we are debugging it.
     136    m_strongVM = &m_globalObject.vm();
     137    m_strongGlobalObject.set(m_globalObject.vm(), &m_globalObject);
    134138
    135139    // FIXME: change this to notify agents which frontend has connected (by id).
     
    163167        m_augmentingClient->inspectorDisconnected();
    164168#endif
    165 }
    166 
    167 void JSGlobalObjectInspectorController::disconnectAllFrontends()
    168 {
    169     // FIXME: change this to notify agents which frontend has disconnected (by id).
    170     m_agents.willDestroyFrontendAndBackend(DisconnectReason::InspectedTargetDestroyed);
    171 
    172     m_frontendRouter->disconnectAllFrontends();
    173 
    174     m_isAutomaticInspection = false;
    175 
    176 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
    177     if (m_augmentingClient)
    178         m_augmentingClient->inspectorDisconnected();
    179 #endif
     169
     170    // Remove our JSGlobalObject and VM references, we are done debugging it.
     171    m_strongGlobalObject.clear();
     172    m_strongVM = nullptr;
    180173}
    181174
     
    316309
    317310} // namespace Inspector
    318 
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h

    r204479 r205033  
    4343class ExecState;
    4444class JSGlobalObject;
    45 class JSValue;
    4645}
    4746
     
    5453class InspectorConsoleAgent;
    5554class InspectorDebuggerAgent;
    56 class InspectorHeapAgent;
    5755class InspectorScriptProfilerAgent;
    5856class JSGlobalObjectConsoleClient;
     
    7371    void connectFrontend(FrontendChannel*, bool isAutomaticInspection);
    7472    void disconnectFrontend(FrontendChannel*);
    75     void disconnectAllFrontends();
    7673
    7774    void dispatchMessageFromFrontend(const String&);
     
    122119    Ref<BackendDispatcher> m_backendDispatcher;
    123120
     121    // Used to keep the JSGlobalObject and VM alive while we are debugging it.
     122    JSC::Strong<JSC::JSGlobalObject> m_strongGlobalObject;
     123    RefPtr<JSC::VM> m_strongVM;
     124
    124125    bool m_includeNativeCallStackWithExceptions { true };
    125126    bool m_isAutomaticInspection { false };
Note: See TracChangeset for help on using the changeset viewer.