Bug 1189122 - Assert when we Suspect() when a CC scan is in progress. r=smaug, a=ritu
authorAndrew McCreight <continuation@gmail.com>
Wed, 29 Jul 2015 20:48:00 +0200
changeset 269139 6db8beae5355037df4bc718b006300e8343e2dfb
parent 269138 683b70313b9df4a843c045c9826c4f3226139ffd
child 269140 250b48c714a0d90ecc0ffe41c2fd2410b434ce2d
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, ritu
bugs1189122
milestone41.0a2
Bug 1189122 - Assert when we Suspect() when a CC scan is in progress. r=smaug, a=ritu 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),