Changeset 74209 in webkit


Ignore:
Timestamp:
Dec 16, 2010 1:11:44 PM (13 years ago)
Author:
andersca@apple.com
Message:

2010-12-16 Anders Carlsson <andersca@apple.com>

Reviewed by Dan Bernstein.

Defer getting a PluginProcessConnection object until the plug-in is initialized
https://bugs.webkit.org/show_bug.cgi?id=51207
<rdar://problem/8731306>

Before this change, we would pass the PluginProcessConnection to the PluginProxy constructor, but not
call PluginProcessConnection::addPluginProxy (which associates the plug-in proxy with the connection)
until the plug-in is initialized.

This could lead to a PluginProxy holding a reference to a PluginProcessConnection when the PluginProxyConnection
itself did not know anything about the PluginProxy. This would happen when a page with plug-ins is opened in a background
tab, with the plug-ins not yet initialized.

Because of this, we could end up in a weird state, where the PluginProcessConnection would think that there are no
more plug-ins alive, and invalidate (and null out) the underlying CoreIPC connection, which would lead to crashes
when trying to send messages to the connection during later initialization.

The fix is to pass the plug-in path to the PluginProxy constructor, and get the connection from PluginProxy::initialize.

PluginProcessConnection object

  • WebProcess/Plugins/PluginProxy.cpp: (WebKit::PluginProxy::create): (WebKit::PluginProxy::PluginProxy): (WebKit::PluginProxy::initialize):
  • WebProcess/Plugins/PluginProxy.h:
  • WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createPlugin):
Location:
trunk/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r74206 r74209  
     12010-12-16  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Defer getting a PluginProcessConnection object until the plug-in is initialized
     6        https://bugs.webkit.org/show_bug.cgi?id=51207
     7        <rdar://problem/8731306>
     8
     9        Before this change, we would pass the PluginProcessConnection to the PluginProxy constructor, but not
     10        call PluginProcessConnection::addPluginProxy (which associates the plug-in proxy with the connection)
     11        until the plug-in is initialized.
     12
     13        This could lead to a PluginProxy holding a reference to a PluginProcessConnection when the PluginProxyConnection
     14        itself did not know anything about the PluginProxy. This would happen when a page with plug-ins is opened in a background
     15        tab, with the plug-ins not yet initialized.
     16
     17        Because of this, we could end up in a weird state, where the PluginProcessConnection would think that there are no
     18        more plug-ins alive, and invalidate (and null out) the underlying CoreIPC connection, which would lead to crashes
     19        when trying to send messages to the connection during later initialization.
     20
     21        The fix is to pass the plug-in path to the PluginProxy constructor, and get the connection from PluginProxy::initialize.
     22       
     23        PluginProcessConnection object
     24        * WebProcess/Plugins/PluginProxy.cpp:
     25        (WebKit::PluginProxy::create):
     26        (WebKit::PluginProxy::PluginProxy):
     27        (WebKit::PluginProxy::initialize):
     28        * WebProcess/Plugins/PluginProxy.h:
     29        * WebProcess/WebPage/WebPage.cpp:
     30        (WebKit::WebPage::createPlugin):
     31
    1322010-12-16  Enrica Casucci  <enrica@apple.com>
    233
  • trunk/WebKit2/WebProcess/Plugins/PluginProxy.cpp

    r74046 r74209  
    3636#include "PluginControllerProxyMessages.h"
    3737#include "PluginProcessConnection.h"
     38#include "PluginProcessConnectionManager.h"
    3839#include "WebCoreArgumentCoders.h"
    3940#include "WebEvent.h"
     
    5152}
    5253
    53 PassRefPtr<PluginProxy> PluginProxy::create(PassRefPtr<PluginProcessConnection> connection)
    54 {
    55     return adoptRef(new PluginProxy(connection));
    56 }
    57 
    58 PluginProxy::PluginProxy(PassRefPtr<PluginProcessConnection> connection)
    59     : m_connection(connection)
     54PassRefPtr<PluginProxy> PluginProxy::create(const String& pluginPath)
     55{
     56    return adoptRef(new PluginProxy(pluginPath));
     57}
     58
     59PluginProxy::PluginProxy(const String& pluginPath)
     60    : m_pluginPath(pluginPath)
    6061    , m_pluginInstanceID(generatePluginInstanceID())
    6162    , m_pluginController(0)
     
    8485    m_pluginController = pluginController;
    8586
     87    ASSERT(!m_connection);
     88    m_connection = PluginProcessConnectionManager::shared().getPluginProcessConnection(m_pluginPath);
     89   
     90    if (!m_connection)
     91        return false;
     92   
    8693    // Add the plug-in proxy before creating the plug-in; it needs to be in the map because CreatePlugin
    8794    // can call back out to the plug-in proxy.
  • trunk/WebKit2/WebProcess/Plugins/PluginProxy.h

    r74046 r74209  
    5353class PluginProxy : public Plugin {
    5454public:
    55     static PassRefPtr<PluginProxy> create(PassRefPtr<PluginProcessConnection>);
     55    static PassRefPtr<PluginProxy> create(const String& pluginPath);
    5656    ~PluginProxy();
    5757
     
    6363
    6464private:
    65     explicit PluginProxy(PassRefPtr<PluginProcessConnection>);
     65    explicit PluginProxy(const String& pluginPath);
    6666
    6767    // Plugin
     
    122122#endif
    123123
     124    String m_pluginPath;
     125
    124126    RefPtr<PluginProcessConnection> m_connection;
    125127    uint64_t m_pluginInstanceID;
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r74164 r74209  
    3333#include "NetscapePlugin.h"
    3434#include "PageOverlay.h"
    35 #include "PluginProcessConnection.h"
    36 #include "PluginProcessConnectionManager.h"
    3735#include "PluginProxy.h"
    3836#include "PluginView.h"
     
    236234
    237235#if ENABLE(PLUGIN_PROCESS)
    238     PluginProcessConnection* pluginProcessConnection = PluginProcessConnectionManager::shared().getPluginProcessConnection(pluginPath);
    239 
    240     if (!pluginProcessConnection)
    241         return 0;
    242 
    243     return PluginProxy::create(pluginProcessConnection);
     236    return PluginProxy::create(pluginPath);
    244237#else
    245238    return NetscapePlugin::create(NetscapePluginModule::getOrCreate(pluginPath));
Note: See TracChangeset for help on using the changeset viewer.