Changeset 73414 in webkit


Ignore:
Timestamp:
Dec 6, 2010 4:57:32 PM (13 years ago)
Author:
andersca@apple.com
Message:

WebProcess crash in NPRemoteObjectMap::invalidate when closing tab
https://bugs.webkit.org/show_bug.cgi?id=50597
<rdar://problem/8655584>

Reviewed by Sam Weinig.

When invalidating the NPRemoteObjectMap, we don't want NPObjectMessageReceiver to
release all objects NPObjects blindly because NPJSObjects have already been deallocated by the plug-in view.

This is not an ideal solution; an ideal solution would involve NPJSObjects notifying any NPObjectMessageReceiver objects
that the NPJSObject is being destroyed. The NPObjectMessageReceiver could then simply null out the NPObject pointer.

  • Shared/Plugins/NPObjectMessageReceiver.cpp:

(WebKit::NPObjectMessageReceiver::NPObjectMessageReceiver):
(WebKit::NPObjectMessageReceiver::~NPObjectMessageReceiver):

  • Shared/Plugins/NPObjectMessageReceiver.h:
  • Shared/Plugins/NPRemoteObjectMap.cpp:

(WebKit::NPRemoteObjectMap::NPRemoteObjectMap):
(WebKit::NPRemoteObjectMap::invalidate):

  • Shared/Plugins/NPRemoteObjectMap.h:

(WebKit::NPRemoteObjectMap::isInvalidating):

Location:
trunk/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r73412 r73414  
     12010-12-06  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        WebProcess crash in NPRemoteObjectMap::invalidate when closing tab
     6        https://bugs.webkit.org/show_bug.cgi?id=50597
     7        <rdar://problem/8655584>
     8
     9        When invalidating the NPRemoteObjectMap, we don't want NPObjectMessageReceiver to
     10        release all objects NPObjects blindly because NPJSObjects have already been deallocated by the plug-in view.
     11
     12        This is not an ideal solution; an ideal solution would involve NPJSObjects notifying any NPObjectMessageReceiver objects
     13        that the NPJSObject is being destroyed. The NPObjectMessageReceiver could then simply null out the NPObject pointer.
     14
     15        * Shared/Plugins/NPObjectMessageReceiver.cpp:
     16        (WebKit::NPObjectMessageReceiver::NPObjectMessageReceiver):
     17        (WebKit::NPObjectMessageReceiver::~NPObjectMessageReceiver):
     18        * Shared/Plugins/NPObjectMessageReceiver.h:
     19        * Shared/Plugins/NPRemoteObjectMap.cpp:
     20        (WebKit::NPRemoteObjectMap::NPRemoteObjectMap):
     21        (WebKit::NPRemoteObjectMap::invalidate):
     22        * Shared/Plugins/NPRemoteObjectMap.h:
     23        (WebKit::NPRemoteObjectMap::isInvalidating):
     24
    1252010-12-06  Sam Weinig  <sam@webkit.org>
    226
  • trunk/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp

    r71559 r73414  
    3333#include "NPVariantData.h"
    3434
     35// FIXME: This code shouldn't know about NPJSObject.
     36#include "NPJSObject.h"
     37
    3538namespace WebKit {
    3639
     
    4447    , m_npObjectID(npObjectID)
    4548    , m_npObject(npObject)
     49    , m_shouldReleaseObjectWhenInvalidating(!NPJSObject::isNPJSObject(npObject))
    4650{
    4751    retainNPObject(m_npObject);
     
    5155{
    5256    m_npRemoteObjectMap->unregisterNPObject(m_npObjectID);
     57
     58    // If we're invalidating the remote object map, we don't always want to release the underlying NPObject.
     59    // One example of this is NPJSObjects in the Web process, which have already been deallocated by the plug-in view.
     60    // FIXME: This is not the ideal way to handle this. Maybe NPObjectMessageReceiver should be notified somehow when the underlying
     61    // NPObject is deallocated.
     62    if (m_npRemoteObjectMap->isInvalidating() && !m_shouldReleaseObjectWhenInvalidating)
     63        return;
    5364
    5465    releaseNPObject(m_npObject);
  • trunk/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h

    r71559 r73414  
    6969    uint64_t m_npObjectID;
    7070    NPObject* m_npObject;
     71    bool m_shouldReleaseObjectWhenInvalidating;
    7172};
    7273   
  • trunk/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp

    r71546 r73414  
    5050NPRemoteObjectMap::NPRemoteObjectMap(CoreIPC::Connection* connection)
    5151    : m_connection(connection)
     52    , m_isInvalidating(false)
    5253{
    5354}
     
    188189void NPRemoteObjectMap::invalidate()
    189190{
     191    ASSERT(!m_isInvalidating);
     192
     193    m_isInvalidating = true;
     194
    190195    Vector<NPObjectMessageReceiver*> messageReceivers;
    191196    copyValuesToVector(m_registeredNPObjects, messageReceivers);
     
    199204        NPObjectProxy::toNPObjectProxy(*it)->invalidate();
    200205    m_npObjectProxies.clear();
     206
     207    m_isInvalidating = false;
    201208}
    202209
  • trunk/WebKit2/Shared/Plugins/NPRemoteObjectMap.h

    r71140 r73414  
    6161
    6262    CoreIPC::Connection* connection() const { return m_connection; }
     63    bool isInvalidating() const { return m_isInvalidating; }
    6364
    6465    void invalidate();
     
    6970    explicit NPRemoteObjectMap(CoreIPC::Connection*);
    7071    CoreIPC::Connection* m_connection;
     72
     73    bool m_isInvalidating;
    7174
    7275    // A map of NPObjectMessageReceiver classes, wrapping objects that we export to the
Note: See TracChangeset for help on using the changeset viewer.