Bug 1357366 - Avoid a possible crash loop in Places Database corruption handling. r=past
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 18 Apr 2017 14:02:43 +0200
changeset 353603 08cfcd3c28c06fda01ddbf4369edd945a604dde9
parent 353602 bb778a3d681e7a58a1634db06f7ff0c9bd44873d
child 353604 ed32ab19afb8c06e18ebb5d905fefd4ce7cb0559
push id31673
push userkwierso@gmail.com
push dateTue, 18 Apr 2017 21:23:54 +0000
treeherdermozilla-central@1a81aadc2510 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1357366
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1357366 - Avoid a possible crash loop in Places Database corruption handling. r=past MozReview-Commit-ID: BIN3ji68nAY
toolkit/components/places/Database.cpp
--- a/toolkit/components/places/Database.cpp
+++ b/toolkit/components/places/Database.cpp
@@ -810,19 +810,23 @@ Database::BackupAndReplaceDatabaseFile(n
 
   return NS_OK;
 }
 
 nsresult
 Database::ForceCrashAndReplaceDatabase(const nsCString& aReason)
 {
   Preferences::SetBool(PREF_FORCE_DATABASE_REPLACEMENT, true);
-  // We could force an application restart here, but we'd like to get these
-  // cases reported to us, so let's force a crash instead.
-  MOZ_CRASH_UNSAFE_OOL(aReason.get());
+  // Ensure that prefs get saved, or we could crash before storing them.
+  nsIPrefService* prefService = Preferences::GetService();
+  if (prefService && NS_SUCCEEDED(prefService->SavePrefFile(nullptr))) {
+    // We could force an application restart here, but we'd like to get these
+    // cases reported to us, so let's force a crash instead.
+    MOZ_CRASH_UNSAFE_OOL(aReason.get());
+  }
   return NS_ERROR_FAILURE;
 }
 
 nsresult
 Database::InitSchema(bool* aDatabaseMigrated)
 {
   MOZ_ASSERT(NS_IsMainThread());
   *aDatabaseMigrated = false;