Bug 1267819: Add a diagnostic assertion. r=froydnj
authorKyle Huey <khuey@kylehuey.com>
Tue, 28 Jun 2016 10:47:23 -0700
changeset 382049 8186a2778f9d184852ee0a7fa369b602fab03111
parent 382048 58954ad707106456fa5f6c2b5787430398a4dd64
child 382050 6aefa79cdaa95f2e6ef0bc4c3a08848fdba24151
child 382165 08f48f6431b98185d5027667c6bbb57896a48e50
push id21599
push usergarndt@mozilla.com
push dateTue, 28 Jun 2016 18:06:27 +0000
reviewersfroydnj
bugs1267819
milestone50.0a1
Bug 1267819: Add a diagnostic assertion. r=froydnj
xpcom/threads/nsEventQueue.cpp
--- a/xpcom/threads/nsEventQueue.cpp
+++ b/xpcom/threads/nsEventQueue.cpp
@@ -52,18 +52,23 @@ nsEventQueue::GetEvent(bool aMayWait, ns
       return false;
     }
     LOG(("EVENTQ(%p): wait begin\n", this));
     mEventsAvailable.Wait();
     LOG(("EVENTQ(%p): wait end\n", this));
   }
 
   if (aResult) {
+    MOZ_ASSERT(mOffsetHead < EVENTS_PER_PAGE);
+    MOZ_ASSERT_IF(mHead == mTail, mOffsetHead <= mOffsetTail);
     *aResult = mHead->mEvents[mOffsetHead++];
 
+    MOZ_ASSERT(*aResult);
+    MOZ_ASSERT(mOffsetHead <= EVENTS_PER_PAGE);
+
     // Check if mHead points to empty Page
     if (mOffsetHead == EVENTS_PER_PAGE) {
       Page* dead = mHead;
       mHead = mHead->mNext;
       FreePage(dead);
       mOffsetHead = 0;
     }
   }