Bug 1357366 - Avoid a possible crash loop in Places Database corruption handling. r=past, a=gchang
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 18 Apr 2017 14:02:43 +0200
changeset 395949 1a74650efe112263c6f65a90bb22ca66ac65d97e
parent 395948 1d567ed511606f6117144252237463eb3ccd5e3e
child 395950 6ed18ad42fc25d212c34b153cd8dcf025674827c
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast, gchang
bugs1357366
milestone54.0
Bug 1357366 - Avoid a possible crash loop in Places Database corruption handling. r=past, a=gchang MozReview-Commit-ID: BIN3ji68nAY
toolkit/components/places/Database.cpp
--- a/toolkit/components/places/Database.cpp
+++ b/toolkit/components/places/Database.cpp
@@ -625,19 +625,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;