Changeset 120143 in webkit


Ignore:
Timestamp:
Jun 12, 2012, 5:23:49 PM (13 years ago)
Author:
leo.yang@torchmobile.com.cn
Message:

Dynamic hash table in DOMObjectHashTableMap is wrong in multiple threads
https://bugs.webkit.org/show_bug.cgi?id=87334

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Add a copy member function to JSC::HasTable. This function will copy all data
members except for *table* which contains thread specific data that prevents
up copying it. When you want to copy a JSC::HashTable that was constructed
on another thread you should call JSC::HashTable::copy().

  • runtime/Lookup.h:

(JSC::HashTable::copy):
(HashTable):

Source/WebCore:

Adapt to JSC::HashTable::copy to avoid copy dynamic table member of a HashTable.
The dynamic table may be allocated on other thread and contains thread specific
identifiers. For example, a hash table of JSEntryArray was first initialized on a
worker thread, and then the user reloaded the page, another worker thread is
created due to reload, the dynamic allocated table in *staticTable* is specific
to the first worker thread which has died. If the user reload the page again,
the dynamic table will be freed and memory corruption will occur.

No functionalities changed, no new tests.

  • bindings/js/DOMObjectHashTableMap.h:

(WebCore::DOMObjectHashTableMap::get):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r120137 r120143  
     12012-06-12  Leo Yang  <leo.yang@torchmobile.com.cn>
     2
     3        Dynamic hash table in DOMObjectHashTableMap is wrong in multiple threads
     4        https://bugs.webkit.org/show_bug.cgi?id=87334
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Add a copy member function to JSC::HasTable. This function will copy all data
     9        members except for *table* which contains thread specific data that prevents
     10        up copying it. When you want to copy a JSC::HashTable that was constructed
     11        on another thread you should call JSC::HashTable::copy().
     12
     13        * runtime/Lookup.h:
     14        (JSC::HashTable::copy):
     15        (HashTable):
     16
    1172012-06-12  Filip Pizlo  <fpizlo@apple.com>
    218
  • trunk/Source/JavaScriptCore/runtime/Lookup.h

    r117859 r120143  
    115115        mutable const HashEntry* table; // Table allocated at runtime.
    116116
     117        ALWAYS_INLINE HashTable copy() const
     118        {
     119            // Don't copy dynamic table since it's thread specific.
     120            HashTable result = { compactSize, compactHashSizeMask, values, 0 };
     121            return result;
     122        }
     123
    117124        ALWAYS_INLINE void initializeIfNeeded(JSGlobalData* globalData) const
    118125        {
  • trunk/Source/WebCore/ChangeLog

    r120142 r120143  
     12012-06-12  Leo Yang  <leo.yang@torchmobile.com.cn>
     2
     3        Dynamic hash table in DOMObjectHashTableMap is wrong in multiple threads
     4        https://bugs.webkit.org/show_bug.cgi?id=87334
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Adapt to JSC::HashTable::copy to avoid copy dynamic table member of a HashTable.
     9        The dynamic table may be allocated on other thread and contains thread specific
     10        identifiers. For example, a hash table of JSEntryArray was first initialized on a
     11        worker thread, and then the user reloaded the page, another worker thread is
     12        created due to reload, the dynamic allocated table in *staticTable* is specific
     13        to the first worker thread which has died. If the user reload the page again,
     14        the dynamic table will be freed and memory corruption will occur.
     15
     16        No functionalities changed, no new tests.
     17
     18        * bindings/js/DOMObjectHashTableMap.h:
     19        (WebCore::DOMObjectHashTableMap::get):
     20
    1212012-06-12  James Robinson  <jamesr@chromium.org>
    222
  • trunk/Source/WebCore/bindings/js/DOMObjectHashTableMap.h

    r112555 r120143  
    4848        if (iter != m_map.end())
    4949            return &iter->second;
    50         return &m_map.set(staticTable, JSC::HashTable(*staticTable)).iterator->second;
     50        return &m_map.set(staticTable, staticTable->copy()).iterator->second;
    5151    }
    5252
Note: See TracChangeset for help on using the changeset viewer.