From 8e88ce043f2c9f3eddbfa24b24d918a2e1c917ee Mon Sep 17 00:00:00 2001 From: Tom Tung Date: Fri, 19 Apr 2019 14:32:53 +0000 Subject: [PATCH] Bug 1528690 - P1 - Mitigate the issue by checking the pointer before accessing it; r=asuth 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 --HG-- extra : moz-landing-system : lando --- dom/indexedDB/ActorsParent.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index fb18c1f96aa1..f051bb08129b 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -9451,7 +9451,7 @@ nsresult DatabaseConnection::CommitWriteTransaction() { void DatabaseConnection::RollbackWriteTransaction() { AssertIsOnConnectionThread(); MOZ_ASSERT(!mInReadTransaction); - MOZ_ASSERT(mStorageConnection); + MOZ_DIAGNOSTIC_ASSERT(mStorageConnection); AUTO_PROFILER_LABEL("DatabaseConnection::RollbackWriteTransaction", DOM); @@ -10063,6 +10063,13 @@ nsresult DatabaseConnection::AutoSavepoint::Start( 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);