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
This commit is contained in:
Tom Tung 2019-04-19 14:32:53 +00:00
Родитель c66fe2ba5d
Коммит 8e88ce043f
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -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);