Changeset 27710 in webkit for trunk/JavaScriptCore/wtf/HashMap.h


Ignore:
Timestamp:
Nov 11, 2007, 10:44:26 PM (18 years ago)
Author:
Adam Roben
Message:

Fix <rdar://5578982> ASSERT in HashTable::checkTableConsistencyExceptSize beneath WebNotificationCenter

The bug was due to a mismatch between HashMap::remove and
HashTable::checkTableConsistency. HashMap::remove can delete the value
stored in the HashTable (by derefing it), which is not normally
allowed by HashTable. It's OK in this case because the value is about
to be removed from the table, but HashTable wasn't aware of this.

HashMap::remove now performs the consistency check itself before
derefing the value.

Darin noticed that the same bug would occur in HashSet, so I've fixed
it there as well.

Reviewed by Darin.

  • wtf/HashMap.h: (WTF::HashMap::remove): Perform the HashTable consistency check manually before calling deref.
  • wtf/HashSet.h: (WTF::HashSet::remove): Ditto.
  • wtf/HashTable.h: Made checkTableConsistency public so that HashMap and HashSet can call it. (WTF::HashTable::removeAndInvalidateWithoutEntryConsistencyCheck): Added. (WTF::HashTable::removeAndInvalidate): Added. (WTF::HashTable::remove): (WTF::HashTable::removeWithoutEntryConsistencyCheck): Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/HashMap.h

    r27385 r27710  
    308308        if (it.m_impl == m_impl.end())
    309309            return;
     310        m_impl.checkTableConsistency();
    310311        RefCounter<ValueTraits, ValueStorageTraits>::deref(*it.m_impl);
    311         m_impl.remove(it.m_impl);
     312        m_impl.removeWithoutEntryConsistencyCheck(it.m_impl);
    312313    }
    313314
Note: See TracChangeset for help on using the changeset viewer.