Ignore:
Timestamp:
Nov 20, 2008, 10:11:14 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=22364
Crashes seen on Tiger buildbots due to worker threads exhausting pthread keys

  • runtime/Collector.cpp: (JSC::Heap::Heap): (JSC::Heap::destroy): (JSC::Heap::makeUsableFromMultipleThreads): (JSC::Heap::registerThread):
  • runtime/Collector.h: Pthread key for tracking threads is only created on request now, because this is a limited resource, and thread tracking is not needed for worker heaps, or for WebCore heap.
  • API/JSContextRef.cpp: (JSGlobalContextCreateInGroup): Call makeUsableFromMultipleThreads().
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::sharedInstance): Ditto.
  • runtime/JSGlobalData.h: (JSC::JSGlobalData::makeUsableFromMultipleThreads): Just forward the call to Heap, which clients need not know about, ideally.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r38528 r38622  
    122122#if ENABLE(JSC_MULTIPLE_THREADS)
    123123    , m_registeredThreads(0)
     124    , m_currentThreadRegistrar(0)
    124125#endif
    125126    , m_globalData(globalData)
    126127{
    127128    ASSERT(globalData);
    128 
    129 #if ENABLE(JSC_MULTIPLE_THREADS)
    130     int error = pthread_key_create(&m_currentThreadRegistrar, unregisterThread);
    131     if (error)
    132         CRASH();
    133 #endif
    134129
    135130    memset(&primaryHeap, 0, sizeof(CollectorHeap));
     
    166161
    167162#if ENABLE(JSC_MULTIPLE_THREADS)
     163    if (m_currentThreadRegistrar) {
    168164#ifndef NDEBUG
    169     int error =
    170 #endif
    171         pthread_key_delete(m_currentThreadRegistrar);
    172     ASSERT(!error);
     165        int error =
     166#endif
     167            pthread_key_delete(m_currentThreadRegistrar);
     168        ASSERT(!error);
     169    }
    173170
    174171    MutexLocker registeredThreadsLock(m_registeredThreadsMutex);
     
    479476}
    480477
     478void Heap::makeUsableFromMultipleThreads()
     479{
     480    if (m_currentThreadRegistrar)
     481        return;
     482
     483    int error = pthread_key_create(&m_currentThreadRegistrar, unregisterThread);
     484    if (error)
     485        CRASH();
     486}
     487
    481488void Heap::registerThread()
    482489{
    483     if (pthread_getspecific(m_currentThreadRegistrar))
     490    if (!m_currentThreadRegistrar || pthread_getspecific(m_currentThreadRegistrar))
    484491        return;
    485492
Note: See TracChangeset for help on using the changeset viewer.