Changeset 103556 in webkit
- Timestamp:
- Dec 22, 2011 10:38:08 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r103555 r103556 1 2011-12-22 Andreas Kling <kling@webkit.org> 2 3 SnowLeopard crashes due to thread-unsafe EventListenerIterator ASSERTs 4 <http://webkit.org/b/74260> 5 6 Reviewed by Darin Adler. 7 8 Guard EventListenerMap::m_activeIteratorCount with a mutex. 9 10 * dom/EventListenerMap.cpp: 11 (WebCore::activeIteratorCountMutex): 12 (WebCore::EventListenerMap::assertNoActiveIterators): 13 (WebCore::EventListenerMap::clear): 14 (WebCore::EventListenerMap::add): 15 (WebCore::EventListenerMap::remove): 16 (WebCore::EventListenerMap::find): 17 (WebCore::EventListenerMap::removeFirstEventListenerCreatedFromMarkup): 18 (WebCore::EventListenerMap::copyEventListenersNotCreatedFromMarkupToTarget): 19 (WebCore::EventListenerIterator::EventListenerIterator): 20 (WebCore::EventListenerIterator::~EventListenerIterator): 21 * dom/EventListenerMap.h: 22 (WebCore::EventListenerMap::assertNoActiveIterators): 23 1 24 2011-12-22 Vsevolod Vlasov <vsevik@chromium.org> 2 25 -
trunk/Source/WebCore/dom/EventListenerMap.cpp
r102349 r103556 40 40 #include <wtf/Vector.h> 41 41 42 #ifndef NDEBUG 43 #include <wtf/Threading.h> 44 #endif 45 42 46 using namespace WTF; 43 47 44 48 namespace WebCore { 49 50 #ifndef NDEBUG 51 static Mutex& activeIteratorCountMutex() 52 { 53 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); 54 return mutex; 55 } 56 57 void EventListenerMap::assertNoActiveIterators() 58 { 59 MutexLocker locker(activeIteratorCountMutex()); 60 ASSERT(!m_activeIteratorCount); 61 } 62 #endif 45 63 46 64 EventListenerMap::EventListenerMap() … … 67 85 void EventListenerMap::clear() 68 86 { 69 ASSERT(!m_activeIteratorCount);87 assertNoActiveIterators(); 70 88 71 89 if (m_hashMap) … … 105 123 bool EventListenerMap::add(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) 106 124 { 107 ASSERT(!m_activeIteratorCount);125 assertNoActiveIterators(); 108 126 109 127 if (m_singleEventListenerVector && m_singleEventListenerType != eventType) { … … 145 163 bool EventListenerMap::remove(const AtomicString& eventType, EventListener* listener, bool useCapture, size_t& indexOfRemovedListener) 146 164 { 147 ASSERT(!m_activeIteratorCount);165 assertNoActiveIterators(); 148 166 149 167 if (!m_hashMap) { … … 170 188 EventListenerVector* EventListenerMap::find(const AtomicString& eventType) 171 189 { 172 ASSERT(!m_activeIteratorCount);190 assertNoActiveIterators(); 173 191 174 192 if (m_hashMap) { … … 204 222 void EventListenerMap::removeFirstEventListenerCreatedFromMarkup(const AtomicString& eventType) 205 223 { 206 ASSERT(!m_activeIteratorCount);224 assertNoActiveIterators(); 207 225 208 226 if (m_hashMap) { … … 243 261 void EventListenerMap::copyEventListenersNotCreatedFromMarkupToTarget(EventTarget* target) 244 262 { 245 ASSERT(!m_activeIteratorCount);263 assertNoActiveIterators(); 246 264 247 265 if (m_hashMap) { … … 279 297 280 298 #ifndef NDEBUG 281 m_map->m_activeIteratorCount++; 299 { 300 MutexLocker locker(activeIteratorCountMutex()); 301 m_map->m_activeIteratorCount++; 302 } 282 303 #endif 283 304 … … 291 312 EventListenerIterator::~EventListenerIterator() 292 313 { 293 if (m_map) 314 if (m_map) { 315 MutexLocker locker(activeIteratorCountMutex()); 294 316 m_map->m_activeIteratorCount--; 317 } 295 318 } 296 319 #endif -
trunk/Source/WebCore/dom/EventListenerMap.h
r102349 r103556 66 66 friend class EventListenerIterator; 67 67 68 void assertNoActiveIterators(); 69 68 70 struct EventListenerHashMapTraits : HashTraits<WTF::AtomicString> { 69 71 static const int minimumTableSize = 32; … … 99 101 }; 100 102 103 #ifdef NDEBUG 104 inline void EventListenerMap::assertNoActiveIterators() { } 105 #endif 106 101 107 } // namespace WebCore 102 108
Note: See TracChangeset
for help on using the changeset viewer.