Bug 1189122 - Assert when we Suspect() when a CC scan is in progress. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Wed, 29 Jul 2015 20:48:00 +0200
changeset 287316 2b0596910897e4aca81eedbcd16860c6ca0c0247
parent 287315 2162bd0f0411001b6ac6303ea2bc9c9f13b46ab6
child 287317 3ceddaebf7e3e1d40a4a0b5b841b13ae241c7fd1
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1189122
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1189122 - Assert when we Suspect() when a CC scan is in progress. r=smaug This can cause leaks that are invisible to our XPCOM leak detection system. To avoid this, classes should not addref or release in their Traverse methods.
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -3417,19 +3417,18 @@ HasParticipant(void* aPtr, nsCycleCollec
 #endif
 
 MOZ_ALWAYS_INLINE void
 nsCycleCollector::Suspect(void* aPtr, nsCycleCollectionParticipant* aParti,
                           nsCycleCollectingAutoRefCnt* aRefCnt)
 {
   CheckThreadSafety();
 
-  // Re-entering ::Suspect during collection used to be a fatal error,
-  // but we are canonicalizing nsISupports pointers using QI, so we
-  // will see some spurious refcount traffic here.
+  // Don't call AddRef or Release of a CCed object in a Traverse() method.
+  MOZ_ASSERT(!mScanInProgress, "Attempted to call Suspect() while a scan was in progress");
 
   if (MOZ_UNLIKELY(mScanInProgress)) {
     return;
   }
 
   MOZ_ASSERT(aPtr, "Don't suspect null pointers");
 
   MOZ_ASSERT(HasParticipant(aPtr, aParti),