Bug 1342067 - Annotate the name of the preference accessed too early in the pre-END_INIT_PREFS phase preference access crash message; r=blassey
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 23 Feb 2017 10:04:45 -0500
changeset 373650 ef1063db138cfbb3e6bb1f01d1e5e27947e53e94
parent 373649 ac8a51344b667d745cf041818d4ebdb009879d87
child 373651 9fe977a59fa1656a0a03b8ea1ad6c873520ef1d2
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs1342067
milestone54.0a1
Bug 1342067 - Annotate the name of the preference accessed too early in the pre-END_INIT_PREFS phase preference access crash message; r=blassey
modules/libpref/prefapi.cpp
--- a/modules/libpref/prefapi.cpp
+++ b/modules/libpref/prefapi.cpp
@@ -778,18 +778,23 @@ PrefHashEntry* pref_HashTableLookup(cons
     MOZ_ASSERT(NS_IsMainThread());
 #endif
     MOZ_ASSERT((!XRE_IsContentProcess() || gPhase != START),
                "pref access before commandline prefs set");
     /* If you're hitting this assertion, you've added a pref access to start up.
      * Consider moving it later or add it to the whitelist in ContentPrefs.cpp
      * and get review from a DOM peer
      */
-    MOZ_ASSERT((!XRE_IsContentProcess() || gPhase > END_INIT_PREFS || gWatchingPref || inInitArray(key)),
-               "accessing non-init pref before the rest of the prefs are sent");
+#ifdef DEBUG
+    if (XRE_IsContentProcess() && gPhase <= END_INIT_PREFS &&
+        !gWatchingPref && !inInitArray(key)) {
+      MOZ_CRASH_UNSAFE_PRINTF("accessing non-init pref %s before the rest of the prefs are sent",
+                              key);
+    }
+#endif
     return static_cast<PrefHashEntry*>(gHashTable->Search(key));
 }
 
 nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t flags)
 {
 #ifndef MOZ_B2G
     MOZ_ASSERT(NS_IsMainThread());
 #endif