VirtualBox

Ignore:
Timestamp:
Oct 26, 2007 5:21:00 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25742
Message:

XPCOM: Fixed memory errors and leaks found by valgrind.

File:
1 edited

Legend:

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

    r1 r5522  
    8484#ifdef NS_DEBUG
    8585  inline nsrefcnt ReleaseQuiet() {
    86       nsAutoOwningThread old = _mOwningThread;
    87       _mOwningThread = nsAutoOwningThread();
    88       nsrefcnt ref = Release();
     86    // shut up NS_ASSERT_OWNINGTHREAD (see explaination below)
     87    nsAutoOwningThread old = _mOwningThread;
     88    _mOwningThread = nsAutoOwningThread();
     89    nsrefcnt ref = Release();
     90    NS_ASSERTION(ref == 0, "the object is still referenced by other threads while it shouldn't");
     91    if (ref != 0)
    8992      _mOwningThread = old;
    90       return ref;
     93    return ref;
    9194  }
    9295#else 
     
    103106#endif
    104107
    105 // Note this object is single threaded - the service itself ensures
    106 // one per thread.
    107 // Exceptions are DropAllThreads (called on the thread shutting down xpcom)
    108 // and ThreadDestruct (called after xpcom destroyed the internal thread struct,
    109 // so that PR_GetCurrentThread() will create a new one from scratch which will
    110 // obviously not match the old one stored in the instance on creation). Since
    111 // these NS_CheckThreadSafe() assertions are quite annoying in the debug build,
    112 // we use a special ReleaseQuiet() mehtod in DoDropThread() to shut them up.
     108// Note: the nsExceptionManager object is single threaded - the exception
     109// service itself ensures one per thread. However, there are two methods that
     110// may be called on foreign threads: DropAllThreads (called on the thread
     111// shutting down xpcom) and ThreadDestruct (called after xpcom destroyed the
     112// internal thread struct, so that PR_GetCurrentThread() will create a new one
     113// from scratch which will obviously not match the old one stored in the
     114// instance on creation). In both cases, there should be no other threads
     115// holding objects (i.e. it's thread-safe to call them), but
     116// NS_CheckThreadSafe() assertions will still happen and yell in the debug
     117// build. Since it is quite annoying, we use a special ReleaseQuiet() mehtod
     118// in DoDropThread() to shut them up.
    113119NS_IMPL_ISUPPORTS1(nsExceptionManager, nsIExceptionManager)
    114120
Note: See TracChangeset for help on using the changeset viewer.

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