Bug 836263 part B - Do custom OOM error reporting in nsPrefBranch::GetComplexValue in the hopes of better diagnosis of a topcrash correlated to a few addons but otherwise very mysterious, r=khuey/ted a=lsblakk
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 08 Mar 2013 12:27:58 -0500
changeset 127706 6a7999f4cc9824ac5937029211dbbb6c3029cf39
parent 127705 b0b5a6da2a166f799b446a001a9884ba91720a51
child 127707 871583c7b8723610230d1a23f4ea5e775e82ad92
push id2256
push userbsmedberg@mozilla.com
push dateMon, 11 Mar 2013 18:39:20 +0000
treeherdermozilla-beta@6a7999f4cc98 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, ted, lsblakk
bugs836263
milestone20.0
Bug 836263 part B - Do custom OOM error reporting in nsPrefBranch::GetComplexValue in the hopes of better diagnosis of a topcrash correlated to a few addons but otherwise very mysterious, r=khuey/ted a=lsblakk
modules/libpref/src/nsPrefBranch.cpp
--- a/modules/libpref/src/nsPrefBranch.cpp
+++ b/modules/libpref/src/nsPrefBranch.cpp
@@ -10,25 +10,30 @@
 #include "nsILocalFile.h" // nsILocalFile used for backwards compatibility
 #include "nsIObserverService.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIDirectoryService.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsXPIDLString.h"
+#include "nsPrintfCString.h"
 #include "nsIStringBundle.h"
 #include "prefapi.h"
 #include "pldhash.h"
 
 #include "nsCRT.h"
 #include "mozilla/Services.h"
 
 #include "prefapi_private_data.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsICrashReporter.h"
+#endif
+
 // Definitions
 struct EnumerateData {
   const char  *parent;
   nsTArray<nsCString> *pref_list;
 };
 
 // Prototypes
 static PLDHashOperator
@@ -303,17 +308,33 @@ NS_IMETHODIMP nsPrefBranch::GetComplexVa
     relativePref.forget(reinterpret_cast<nsIRelativeFilePref**>(_retval));
     return NS_OK;
   }
 
   if (aType.Equals(NS_GET_IID(nsISupportsString))) {
     nsCOMPtr<nsISupportsString> theString(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv));
 
     if (NS_SUCCEEDED(rv)) {
-      theString->SetData(NS_ConvertUTF8toUTF16(utf8String));
+      // Debugging to see why we end up with very long strings here with
+      // some addons, see bug 836263.
+      nsAutoString wdata;
+      if (!AppendUTF8toUTF16(utf8String, wdata, mozilla::fallible_t())) {
+#ifdef MOZ_CRASHREPORTER
+        nsCOMPtr<nsICrashReporter> cr =
+          do_GetService("@mozilla.org/toolkit/crash-reporter;1");
+        if (cr) {
+          cr->AnnotateCrashReport(NS_LITERAL_CSTRING("bug836263-size"),
+                                  nsPrintfCString("%x", utf8String.Length()));
+          cr->RegisterAppMemory(uint64_t(utf8String.BeginReading()),
+                                std::min(0x1000U, utf8String.Length()));
+        }
+#endif
+        NS_RUNTIMEABORT("bug836263");
+      }
+      theString->SetData(wdata);
       theString.forget(reinterpret_cast<nsISupportsString**>(_retval));
     }
     return rv;
   }
 
   NS_WARNING("nsPrefBranch::GetComplexValue - Unsupported interface type");
   return NS_NOINTERFACE;
 }