Bug 1242084 - nsTerminator::UpdateTelemetry() leaks 8 byte nsStringBuffer when app.update.channel gets set to Beta. r=gfritzsche
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Mon, 14 Mar 2016 06:12:00 +0100
changeset 288536 2602e9da8592ce52e68a22203881ab238506cc94
parent 288535 201d6b255e36072ec586e73fe15c084b7b8e7728
child 288537 21077a8abccf547e9ff9d40629902a676626544e
push id18163
push useralessio.placitelli@gmail.com
push dateMon, 14 Mar 2016 17:38:57 +0000
treeherderfx-team@2602e9da8592 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1242084
milestone48.0a1
Bug 1242084 - nsTerminator::UpdateTelemetry() leaks 8 byte nsStringBuffer when app.update.channel gets set to Beta. r=gfritzsche
toolkit/components/terminator/nsTerminator.cpp
toolkit/components/terminator/tests/xpcshell/xpcshell.ini
--- a/toolkit/components/terminator/nsTerminator.cpp
+++ b/toolkit/components/terminator/nsTerminator.cpp
@@ -353,17 +353,22 @@ nsTerminator::SelfInit()
 }
 
 // Actually launch these threads. This takes place at the first sign of shutdown.
 void
 nsTerminator::Start()
 {
   MOZ_ASSERT(!mInitialized);
   StartWatchdog();
+#if !defined(DEBUG)
+  // Only allow nsTerminator to write on non-debug builds so we don't get leak warnings on
+  // shutdown for intentional leaks (see bug 1242084). This will be enabled again by bug
+  // 1255484 when 1255478 lands.
   StartWriter();
+#endif // !defined(DEBUG)
   mInitialized = true;
 }
 
 // Prepare, allocate and start the watchdog thread.
 // By design, it will never finish, nor be deallocated.
 void
 nsTerminator::StartWatchdog()
 {
@@ -394,17 +399,16 @@ nsTerminator::StartWatchdog()
 }
 
 // Prepare, allocate and start the writer thread. By design, it will never
 // finish, nor be deallocated. In case of error, we degrade
 // gracefully to not writing Telemetry data.
 void
 nsTerminator::StartWriter()
 {
-
   if (!Telemetry::CanRecordExtended()) {
     return;
   }
   nsCOMPtr<nsIFile> profLD;
   nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR,
                                        getter_AddRefs(profLD));
   if (NS_FAILED(rv)) {
     return;
@@ -443,17 +447,22 @@ nsTerminator::Observe(nsISupports *, con
   // As we have seen examples in the wild of shutdown notifications
   // not being sent (or not being sent in the expected order), we do
   // not assume a specific order.
   if (!mInitialized) {
     Start();
   }
 
   UpdateHeartbeat(aTopic);
+#if !defined(DEBUG)
+  // Only allow nsTerminator to write on non-debug builds so we don't get leak warnings on
+  // shutdown for intentional leaks (see bug 1242084). This will be enabled again by bug
+  // 1255484 when 1255478 lands.
   UpdateTelemetry();
+#endif // !defined(DEBUG)
   UpdateCrashReport(aTopic);
 
   // Perform a little cleanup
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   MOZ_RELEASE_ASSERT(os);
   (void)os->RemoveObserver(this, aTopic);
 
   return NS_OK;
--- a/toolkit/components/terminator/tests/xpcshell/xpcshell.ini
+++ b/toolkit/components/terminator/tests/xpcshell/xpcshell.ini
@@ -1,7 +1,8 @@
 [DEFAULT]
 head=
 tail=
 
 [test_terminator_record.js]
+skip-if = debug # Disabled by bug 1242084, bug 1255484 will enable it again.
 [test_terminator_reload.js]
 skip-if = (os == "android" || appname == "b2g")