Bug 1528690 - P1 - Mitigate the issue by checking the pointer before accessing it. r=asuth a=RyanVM
authorTom Tung <shes050117@gmail.com>
Fri, 19 Apr 2019 14:32:53 +0000
changeset 523275 ba1cb4f5a1cf8883cf7bd344cc4b8e16f411c621
parent 523274 b196e0c2e6a883a027266d6d11d647e9ef259599
child 523276 00567ac38963b491628cc9d70e131ffd4f67b029
push id11125
push usernbeleuzu@mozilla.com
push dateMon, 22 Apr 2019 16:37:45 +0000
treeherdermozilla-beta@ceb8833f34c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, RyanVM
bugs1528690
milestone67.0
Bug 1528690 - P1 - Mitigate the issue by checking the pointer before accessing it. r=asuth a=RyanVM The real problem is because the connection was closed for some reason. This patch won't resolve the issue by only let the operation and the transaction fail to escape from the crash. Note that it also changing an assertion when the transaction is either commiting or aborting. This is prevent the problem for closing connection is worser than we expected. Differential Revision: https://phabricator.services.mozilla.com/D28148
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -9473,17 +9473,17 @@ nsresult DatabaseConnection::CommitWrite
 
   mInWriteTransaction = false;
   return NS_OK;
 }
 
 void DatabaseConnection::RollbackWriteTransaction() {
   AssertIsOnConnectionThread();
   MOZ_ASSERT(!mInReadTransaction);
-  MOZ_ASSERT(mStorageConnection);
+  MOZ_DIAGNOSTIC_ASSERT(mStorageConnection);
 
   AUTO_PROFILER_LABEL("DatabaseConnection::RollbackWriteTransaction", DOM);
 
   if (!mInWriteTransaction) {
     return;
   }
 
   DatabaseConnection::CachedStatement stmt;
@@ -10085,16 +10085,23 @@ nsresult DatabaseConnection::AutoSavepoi
              aTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH ||
              aTransaction->GetMode() == IDBTransaction::CLEANUP ||
              aTransaction->GetMode() == IDBTransaction::VERSION_CHANGE);
 
   DatabaseConnection* connection = aTransaction->GetDatabase()->GetConnection();
   MOZ_ASSERT(connection);
   connection->AssertIsOnConnectionThread();
 
+  // This is just a quick fix for preventing accessing the nullptr. The cause is
+  // probably because the connection was unexpectedly closed.
+  if (!connection->GetUpdateRefcountFunction()) {
+    NS_WARNING("The connection was closed for some reasons!");
+    return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
+  }
+
   MOZ_ASSERT(!mConnection);
   MOZ_ASSERT(!mDEBUGTransaction);
 
   nsresult rv = connection->StartSavepoint();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }