⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185717 in webkit


Ignore:
Timestamp:
Jun 18, 2015, 12:32:15 PM (11 years ago)
Author:
Conrad Shultz
Message:

REGRESSION: js/dom/navigator-plugins-crash.html asserts a lot
https://bugs.webkit.org/show_bug.cgi?id=144399

Reviewed by Darin Adler.

Earlier work made the array of web-visible plug-ins dynamic, but allowed DOMPlugin (and, indirectly by extension,
DOMMimeType) to continue keeping a reference to a plug-in in terms of an index into that array. This superficially
appeared correct since DOMPlugin immutably holds onto a PluginData instance, which in turn immutably holds onto a
Page instance. PluginStrategy::getWebVisiblePluginInfo() is passed this Page, which is used to determine the contents
of the plugin array. The expectation was that keeping an index would still be safe since the Page is not changing,
but this is not strictly correct since relevant attributes of the Page and/or the available plugins may still change.

It's not entirely clear why the test failures are intermittent and occur only on certain configurations, but address
them by eliminating the incorrect storage of indexes in favor of keeping copies of the relevant plugin info itself.

  • plugins/DOMMimeType.cpp:

(WebCore::DOMMimeType::DOMMimeType):
Instead of storing the MIME type index, retrieve and store the MIME class info and plugin info.
(WebCore::DOMMimeType::type):
Directly access the m_mimeClassInfo member.
(WebCore::DOMMimeType::suffixes):
Ditto.
(WebCore::DOMMimeType::description):
Ditto.
(WebCore::DOMMimeType::enabledPlugin):
Directly access the m_pluginInfo member.
(WebCore::DOMMimeType::mimeClassInfo): Deleted.

  • plugins/DOMMimeType.h:

Update member variables.

  • plugins/DOMPlugin.cpp:

(WebCore::DOMPlugin::DOMPlugin):
Instead of storing the plugin index, store the plugin info directly.
(WebCore::DOMPlugin::name):
Directly access m_pluginInfo.
(WebCore::DOMPlugin::filename):
Ditto.
(WebCore::DOMPlugin::description):
Ditto.
(WebCore::DOMPlugin::length):
Ditto.
(WebCore::DOMPlugin::item):
Access m_pluginInfo directly; find the matching plug-in based on matching PluginInfo (for which an overloaded
comparator is supplied below).
(WebCore::DOMPlugin::pluginInfo): Deleted.

  • plugins/DOMPlugin.h:

Update member variables.
(WebCore::DOMPlugin::create):
Accept a PluginInfo instead of a plugin index.

  • plugins/DOMPluginArray.cpp:

(WebCore::DOMPluginArray::item):
(WebCore::DOMPluginArray::namedItem):

  • plugins/PluginData.h:

(WebCore::operator==):
Added; compare PluginInfo structs on the basis of member equality.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185714 r185717  
     12015-06-17  Conrad Shultz  <conrad_shultz@apple.com>
     2
     3        REGRESSION: js/dom/navigator-plugins-crash.html asserts a lot
     4        https://bugs.webkit.org/show_bug.cgi?id=144399
     5
     6        Reviewed by Darin Adler.
     7
     8        Earlier work made the array of web-visible plug-ins dynamic, but allowed DOMPlugin (and, indirectly by extension,
     9        DOMMimeType) to continue keeping a reference to a plug-in in terms of an index into that array. This superficially
     10        appeared correct since DOMPlugin immutably holds onto a PluginData instance, which in turn immutably holds onto a
     11        Page instance. PluginStrategy::getWebVisiblePluginInfo() is passed this Page, which is used to determine the contents
     12        of the plugin array. The expectation was that keeping an index would still be safe since the Page is not changing,
     13        but this is not strictly correct since relevant attributes of the Page and/or the available plugins may still change.
     14
     15        It's not entirely clear why the test failures are intermittent and occur only on certain configurations, but address
     16        them by eliminating the incorrect storage of indexes in favor of keeping copies of the relevant plugin info itself.
     17
     18        * plugins/DOMMimeType.cpp:
     19        (WebCore::DOMMimeType::DOMMimeType):
     20        Instead of storing the MIME type index, retrieve and store the MIME class info and plugin info.
     21        (WebCore::DOMMimeType::type):
     22        Directly access the m_mimeClassInfo member.
     23        (WebCore::DOMMimeType::suffixes):
     24        Ditto.
     25        (WebCore::DOMMimeType::description):
     26        Ditto.
     27        (WebCore::DOMMimeType::enabledPlugin):
     28        Directly access the m_pluginInfo member.
     29        (WebCore::DOMMimeType::mimeClassInfo): Deleted.
     30
     31        * plugins/DOMMimeType.h:
     32        Update member variables.
     33
     34        * plugins/DOMPlugin.cpp:
     35        (WebCore::DOMPlugin::DOMPlugin):
     36        Instead of storing the plugin index, store the plugin info directly.
     37        (WebCore::DOMPlugin::name):
     38        Directly access m_pluginInfo.
     39        (WebCore::DOMPlugin::filename):
     40        Ditto.
     41        (WebCore::DOMPlugin::description):
     42        Ditto.
     43        (WebCore::DOMPlugin::length):
     44        Ditto.
     45        (WebCore::DOMPlugin::item):
     46        Access m_pluginInfo directly; find the matching plug-in based on matching PluginInfo (for which an overloaded
     47        comparator is supplied below).
     48        (WebCore::DOMPlugin::pluginInfo): Deleted.
     49
     50        * plugins/DOMPlugin.h:
     51        Update member variables.
     52        (WebCore::DOMPlugin::create):
     53        Accept a PluginInfo instead of a plugin index.
     54
     55        * plugins/DOMPluginArray.cpp:
     56        (WebCore::DOMPluginArray::item):
     57        (WebCore::DOMPluginArray::namedItem):
     58
     59        * plugins/PluginData.h:
     60        (WebCore::operator==):
     61        Added; compare PluginInfo structs on the basis of member equality.
     62
    1632015-06-17  Alex Christensen  <achristensen@webkit.org>
    264
  • trunk/Source/WebCore/plugins/DOMMimeType.cpp

    r182617 r185717  
    3333    : FrameDestructionObserver(frame)
    3434    , m_pluginData(pluginData)
    35     , m_index(index)
    3635{
     36    Vector<MimeClassInfo> mimes;
     37    Vector<size_t> mimePluginIndices;
     38    m_pluginData->getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices);
     39    m_mimeClassInfo = mimes[index];
     40    m_pluginInfo = m_pluginData->webVisiblePlugins()[mimePluginIndices[index]];
    3741}
    3842
     
    4347String DOMMimeType::type() const
    4448{
    45     return mimeClassInfo().type;
     49    return m_mimeClassInfo.type;
    4650}
    4751
    4852String DOMMimeType::suffixes() const
    4953{
    50     const Vector<String>& extensions = mimeClassInfo().extensions;
     54    const Vector<String>& extensions = m_mimeClassInfo.extensions;
    5155
    5256    StringBuilder builder;
     
    6165String DOMMimeType::description() const
    6266{
    63     return mimeClassInfo().desc;
    64 }
    65 
    66 MimeClassInfo DOMMimeType::mimeClassInfo() const
    67 {
    68     Vector<MimeClassInfo> mimes;
    69     Vector<size_t> mimePluginIndices;
    70     m_pluginData->getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices);
    71     return mimes[m_index];
     67    return m_mimeClassInfo.desc;
    7268}
    7369
     
    8076    Vector<size_t> mimePluginIndices;
    8177    m_pluginData->getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices);
    82     return DOMPlugin::create(m_pluginData.get(), m_frame, mimePluginIndices[m_index]);
     78    return DOMPlugin::create(m_pluginData.get(), m_frame, m_pluginInfo);
    8379}
    8480
  • trunk/Source/WebCore/plugins/DOMMimeType.h

    r182617 r185717  
    4343
    4444private:
    45     MimeClassInfo mimeClassInfo() const;
    46 
    4745    DOMMimeType(PassRefPtr<PluginData>, Frame*, unsigned index);
     46    MimeClassInfo m_mimeClassInfo;
    4847    RefPtr<PluginData> m_pluginData;
    49     unsigned m_index;
     48    PluginInfo m_pluginInfo;
    5049};
    5150
  • trunk/Source/WebCore/plugins/DOMPlugin.cpp

    r184990 r185717  
    2626namespace WebCore {
    2727
    28 DOMPlugin::DOMPlugin(PluginData* pluginData, Frame* frame, unsigned index)
     28DOMPlugin::DOMPlugin(PluginData* pluginData, Frame* frame, PluginInfo pluginInfo)
    2929    : FrameDestructionObserver(frame)
    3030    , m_pluginData(pluginData)
    31     , m_index(index)
     31    , m_pluginInfo(WTF::move(pluginInfo))
    3232{
    3333}
     
    3939String DOMPlugin::name() const
    4040{
    41     return pluginInfo().name;
     41    return m_pluginInfo.name;
    4242}
    4343
    4444String DOMPlugin::filename() const
    4545{
    46     return pluginInfo().file;
     46    return m_pluginInfo.file;
    4747}
    4848
    4949String DOMPlugin::description() const
    5050{
    51     return pluginInfo().desc;
     51    return m_pluginInfo.desc;
    5252}
    5353
    5454unsigned DOMPlugin::length() const
    5555{
    56     return pluginInfo().mimes.size();
    57 }
    58 
    59 PluginInfo DOMPlugin::pluginInfo() const
    60 {
    61     return m_pluginData->webVisiblePlugins()[m_index];
     56    return m_pluginInfo.mimes.size();
    6257}
    6358
    6459PassRefPtr<DOMMimeType> DOMPlugin::item(unsigned index)
    6560{
    66     if (index >= pluginInfo().mimes.size())
     61    if (index >= m_pluginInfo.mimes.size())
    6762        return 0;
    6863
    69     MimeClassInfo mime = pluginInfo().mimes[index];
     64    MimeClassInfo mime = m_pluginInfo.mimes[index];
    7065
    7166    Vector<MimeClassInfo> mimes;
    7267    Vector<size_t> mimePluginIndices;
     68    Vector<PluginInfo> plugins = m_pluginData->webVisiblePlugins();
    7369    m_pluginData->getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices);
    7470    for (unsigned i = 0; i < mimes.size(); ++i) {
    75         if (mimes[i] == mime && mimePluginIndices[i] == m_index)
     71        if (mimes[i] == mime && plugins[mimePluginIndices[i]] == m_pluginInfo)
    7672            return DOMMimeType::create(m_pluginData.get(), m_frame, i);
    7773    }
  • trunk/Source/WebCore/plugins/DOMPlugin.h

    r182617 r185717  
    3434class DOMPlugin : public ScriptWrappable, public RefCounted<DOMPlugin>, public FrameDestructionObserver {
    3535public:
    36     static Ref<DOMPlugin> create(PluginData* pluginData, Frame* frame, unsigned index) { return adoptRef(*new DOMPlugin(pluginData, frame, index)); }
     36    static Ref<DOMPlugin> create(PluginData* pluginData, Frame* frame, PluginInfo pluginInfo) { return adoptRef(*new DOMPlugin(pluginData, frame, WTF::move(pluginInfo))); }
    3737    ~DOMPlugin();
    3838
     
    4848
    4949private:
    50     PluginInfo pluginInfo() const;
    51 
    52     DOMPlugin(PluginData*, Frame*, unsigned index);
     50    DOMPlugin(PluginData*, Frame*, PluginInfo);
    5351    RefPtr<PluginData> m_pluginData;
    54     unsigned m_index;
     52    PluginInfo m_pluginInfo;
    5553};
    5654
  • trunk/Source/WebCore/plugins/DOMPluginArray.cpp

    r184990 r185717  
    6262    if (index >= plugins.size())
    6363        return 0;
    64     return DOMPlugin::create(data, m_frame, index);
     64    return DOMPlugin::create(data, m_frame, plugins[index]);
    6565}
    6666
     
    8484        return 0;
    8585
    86     const Vector<PluginInfo>& plugins = data->webVisiblePlugins();
    87     for (unsigned i = 0; i < plugins.size(); ++i) {
    88         if (plugins[i].name == propertyName)
    89             return DOMPlugin::create(data, m_frame, i);
     86    for (auto& plugin : data->webVisiblePlugins()) {
     87        if (plugin.name == propertyName)
     88            return DOMPlugin::create(data, m_frame, plugin);
    9089    }
    9190    return 0;
  • trunk/Source/WebCore/plugins/PluginData.h

    r182617 r185717  
    7474};
    7575
     76inline bool operator==(PluginInfo& a, PluginInfo& b)
     77{
     78    bool result = a.name == b.name && a.file == b.file && a.desc == b.desc && a.mimes == b.mimes && a.isApplicationPlugin == b.isApplicationPlugin && a.clientLoadPolicy == b.clientLoadPolicy;
     79#if PLATFORM(MAC)
     80    result = result && a.bundleIdentifier == b.bundleIdentifier && a.versionString == b.versionString;
     81#endif
     82    return result;
     83}
     84
    7685// FIXME: merge with PluginDatabase in the future
    7786class PluginData : public RefCounted<PluginData> {
Note: See TracChangeset for help on using the changeset viewer.