VirtualBox

Ignore:
Timestamp:
Jul 11, 2016 6:14:11 PM (8 years ago)
Author:
vboxsync
Message:

XPCOM: Change the shutdown order in nsExceptionService, attempting to fix a sporadic crash. The biggest change is postponing the lock freeing to the destructor. The order change of the operations in the Shutdown method eliminates the concerns mention in the ThreadDestruct method. The change in DoDropThread is pure paranoia, intended to avoid potential crashes due to continuing with a NULL pointer in *emp if the thread is not known.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/base/nsExceptionService.cpp

    r56585 r62170  
    8484#ifdef NS_DEBUG
    8585  inline nsrefcnt ReleaseQuiet() {
    86     // shut up NS_ASSERT_OWNINGTHREAD (see explaination below)
     86    // shut up NS_ASSERT_OWNINGTHREAD (see explanation below)
    8787    nsAutoOwningThread old = _mOwningThread;
    8888    _mOwningThread = nsAutoOwningThread();
     
    115115// holding objects (i.e. it's thread-safe to call them), but
    116116// NS_CheckThreadSafe() assertions will still happen and yell in the debug
    117 // build. Since it is quite annoying, we use a special ReleaseQuiet() mehtod
     117// build. Since it is quite annoying, we use a special ReleaseQuiet() method
    118118// in DoDropThread() to shut them up.
    119119NS_IMPL_THREADSAFE_ISUPPORTS1(nsExceptionManager, nsIExceptionManager)
     
    165165
    166166PRUintn nsExceptionService::tlsIndex = BAD_TLS_INDEX;
    167 PRLock *nsExceptionService::lock = PR_FALSE;
     167PRLock *nsExceptionService::lock = nsnull;
    168168nsExceptionManager *nsExceptionService::firstThread = nsnull;
    169169
     
    201201{
    202202  Shutdown();
     203  if (lock) {
     204    PRLock *tmp = lock;
     205    lock = nsnull;
     206    PR_DestroyLock(tmp);
     207  }
    203208  /* destructor code */
    204209#ifdef NS_DEBUG
     
    211216{
    212217  if (!lock) {
    213     // a typical situation is when IPC worker threads that have instantiated
    214     // exception managers are stopped after nsExceptionService is shut down,
    215     // which will result into this warning.  disable it.
    216 #if 0   
    217218    NS_WARNING("nsExceptionService ignoring thread destruction after shutdown");
    218 #endif   
    219219    return;
    220220  }
     
    225225void nsExceptionService::Shutdown()
    226226{
     227  PR_SetThreadPrivate(tlsIndex, nsnull);
    227228  mProviders.Reset();
    228229  if (lock) {
    229230    DropAllThreads();
    230     PR_DestroyLock(lock);
    231     lock = nsnull;
    232   }
    233   PR_SetThreadPrivate(tlsIndex, nsnull);
     231  }
    234232}
    235233
     
    356354    nsExceptionManager **emp = &firstThread;
    357355    while (*emp != thread) {
    358         NS_ABORT_IF_FALSE(*emp, "Could not find the thread to drop!");
     356        if (!*emp)
     357        {
     358            NS_WARNING("Could not find the thread to drop!");
     359            return;
     360        }
    359361        emp = &(*emp)->mNextThread;
    360362    }
    361363    *emp = thread->mNextThread;
    362364    thread->ReleaseQuiet();
    363     thread = 0;
     365    thread = nsnull;
    364366}
    365367
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette