Bug 757025 - Guard against a null mObservers which is possible due to a race condition on some platforms. r=cjones a=johnath
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 24 May 2012 13:53:40 -0400
changeset 95877 8b330f11e7809897c232a39d9747c5113f55fac4
parent 95876 ef414707a0d6d85bba62656eba37bd6ac3fd9e70
child 95878 3a0cedb8ececd5ceee4bbc867bbbc0547c9e5f39
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones, johnath
bugs757025
milestone14.0a2
Bug 757025 - Guard against a null mObservers which is possible due to a race condition on some platforms. r=cjones a=johnath
hal/Hal.cpp
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -202,17 +202,24 @@ public:
       OnNotificationsDisabled();
 
       delete mObservers;
       mObservers = 0;
     }
   }
 
   void BroadcastInformation(const InfoType& aInfo) {
-    MOZ_ASSERT(mObservers);
+    // It is possible for mObservers to be NULL here on some platforms,
+    // because a call to BroadcastInformation gets queued up asynchronously
+    // while RemoveObserver is running (and before the notifications are
+    // disabled). The queued call can then get run after mObservers has
+    // been nulled out. See bug 757025.
+    if (!mObservers) {
+      return;
+    }
     mObservers->Broadcast(aInfo);
   }
 
 protected:
   virtual void EnableNotifications() = 0;
   virtual void DisableNotifications() = 0;
   virtual void OnNotificationsDisabled() {}