Bug 639885 - Abort the program execution if the status of program is unsafe due to thread safety issues in ReadbackManagerD3D10; r=Bas,jrmuizel,cjones a=beltzner
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 09 Mar 2011 09:49:29 -0500
changeset 63365 cae1cd4aae738d6702bcc80eef63722e9a184292
parent 63362 d205dbeada8c3bc3c6ff1649a6f1020d9b58e282
child 63366 439f8db100d7d77257c5edbe3436e95e5e347002
push idunknown
push userunknown
push dateunknown
reviewersBas, jrmuizel, cjones, beltzner
bugs639885
milestone2.0b13pre
Bug 639885 - Abort the program execution if the status of program is unsafe due to thread safety issues in ReadbackManagerD3D10; r=Bas,jrmuizel,cjones a=beltzner
gfx/layers/d3d10/ReadbackManagerD3D10.cpp
--- a/gfx/layers/d3d10/ReadbackManagerD3D10.cpp
+++ b/gfx/layers/d3d10/ReadbackManagerD3D10.cpp
@@ -152,17 +152,17 @@ ReadbackManagerD3D10::~ReadbackManagerD3
   // to leak the thread and its synchronisation in favor of crashing or freezing
   DWORD result = ::WaitForSingleObject(mTaskThread, 5000);
   if (result != WAIT_TIMEOUT) {
     ::DeleteCriticalSection(&mTaskMutex);
     ::CloseHandle(mShutdownEvent);
     ::CloseHandle(mTaskSemaphore);
     ::CloseHandle(mTaskThread);
   } else {
-    NS_WARNING("ReadbackManager: Task thread did not shutdown in 5 seconds. Leaking.");
+    NS_RUNTIMEABORT("ReadbackManager: Task thread did not shutdown in 5 seconds.");
   }
 }
 
 void
 ReadbackManagerD3D10::PostTask(ID3D10Texture2D *aTexture, void *aUpdate, const gfxPoint &aOrigin)
 {
   ReadbackTask *task = new ReadbackTask;
   task->mReadbackTexture = aTexture;
@@ -222,16 +222,19 @@ ReadbackManagerD3D10::ProcessTasks()
   
   while (true) {
     DWORD result = ::WaitForMultipleObjects(2, handles, FALSE, INFINITE);
     if (result != WAIT_OBJECT_0) {
       return;
     }
 
     ::EnterCriticalSection(&mTaskMutex);
+    if (mPendingReadbackTasks.Length() == 0) {
+      NS_RUNTIMEABORT("Trying to read from an empty array, bad bad bad");
+    }
     ReadbackTask *nextReadbackTask = mPendingReadbackTasks[0].forget();
     mPendingReadbackTasks.RemoveElementAt(0);
     ::LeaveCriticalSection(&mTaskMutex);
 
     // We want to block here until the texture contents are available, the
     // easiest thing is to simply map and unmap.
     D3D10_MAPPED_TEXTURE2D mappedTex;
     nextReadbackTask->mReadbackTexture->Map(0, D3D10_MAP_READ, 0, &mappedTex);