From 759e351de7efc132183039290b9d48c6ff5dbb22 Mon Sep 17 00:00:00 2001 From: Andrew Sutherland Date: Mon, 29 Mar 2010 10:54:41 -0700 Subject: [PATCH] Bug 555124 - Intermittent "ASSERTION: AsyncStatementSpinner not thread-safe: '_mOwningThread.GetThread() == PR_GetCurrentThread()', file .../mozilla/storage/test/test_true_async.cpp, line 162". null out references on the main thread to avoid destruction on the async thread. r=sdwilsh. --- storage/src/mozStorageConnection.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/storage/src/mozStorageConnection.cpp b/storage/src/mozStorageConnection.cpp index 51d32869728c..5eeb98647a06 100644 --- a/storage/src/mozStorageConnection.cpp +++ b/storage/src/mozStorageConnection.cpp @@ -283,6 +283,18 @@ public: if (mCallbackEvent) (void)mCallingThread->Dispatch(mCallbackEvent, NS_DISPATCH_NORMAL); + // Because we have no guarantee that the invocation of this method on the + // asynchronous thread has fully completed (including the Release of the + // reference to this object held by that event loop), we need to explicitly + // null out our pointers here. It is possible this object will be destroyed + // on the asynchronous thread and if the references are still alive we will + // release them on that thread. We definitely do not want that for + // mConnection and it's nice to avoid for mCallbackEvent too. We do not + // null out mCallingThread because it is conceivable the async thread might + // still be 'in' the object. + mConnection = nsnull; + mCallbackEvent = nsnull; + return NS_OK; } private: