Bug 1508627: Remove dangerous assertion from nsCOMPtr r=froydnj
authorYaron Tausky <ytausky@mozilla.com>
Wed, 21 Nov 2018 14:50:58 +0000
changeset 503909 dbb1558cb40e071e67fe4fcab5e92b2d25fb03f6
parent 503908 08c81bf2175844b1457258baec46dfd65c596914
child 503910 1e076b0054ccefb1dbbb89e885277e8d1d152832
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1508627
milestone65.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 1508627: Remove dangerous assertion from nsCOMPtr r=froydnj Move constructors and assignment operators are expected to be safe and infallible. In debug mode, nsCOMPtr's move functions called a test function that modified the pointee's refcount -- a potentially thread unsafe operation that also opened the door to assertion failures if the pointee implemented some access checks in AddRef() or Release(). This commit removes this function call in those two functions. Differential Revision: https://phabricator.services.mozilla.com/D12422
xpcom/base/nsCOMPtr.h
--- a/xpcom/base/nsCOMPtr.h
+++ b/xpcom/base/nsCOMPtr.h
@@ -549,17 +549,16 @@ public:
   }
 
   nsCOMPtr(nsCOMPtr<T>&& aSmartPtr)
     : NSCAP_CTOR_BASE(aSmartPtr.mRawPtr)
   {
     assert_validity();
     aSmartPtr.mRawPtr = nullptr;
     NSCAP_LOG_ASSIGNMENT(this, mRawPtr);
-    NSCAP_ASSERT_NO_QUERY_NEEDED();
   }
 
   template <class U>
   MOZ_IMPLICIT nsCOMPtr(nsCOMPtr<U>&& aSmartPtr)
     : NSCAP_CTOR_BASE(aSmartPtr.forget().template downcast<T>().take())
   {
     // Make sure that U actually inherits from T
     static_assert(mozilla::IsBaseOf<T, U>::value,
@@ -728,17 +727,16 @@ public:
                   "U should be a subclass of T");
     assign_with_AddRef(static_cast<T*>(aRhs.get()));
     return *this;
   }
 
   nsCOMPtr<T>& operator=(nsCOMPtr<T>&& aRhs)
   {
     assign_assuming_AddRef(aRhs.forget().take());
-    NSCAP_ASSERT_NO_QUERY_NEEDED();
     return *this;
   }
 
   template<class U>
   nsCOMPtr<T>& operator=(nsCOMPtr<U>&& aRhs)
   {
     // Make sure that U actually inherits from T
     static_assert(mozilla::IsBaseOf<T, U>::value,