Bug 1526328 - Disable Telemetry recording in FUZZING builds. r=janerik
☠☠ backed out by 68e3ee13edd9 ☠ ☠
authorChristian Holler <choller@mozilla.com>
Mon, 11 Feb 2019 13:54:28 +0000
changeset 458497 442a1725c992f43393f4b0dcee1d6fbacf0963c1
parent 458496 4c4f5992c89e31b32a14df8663d9ff1a71f326a0
child 458498 dde4b763ff9b11df8c30778c6231d167ee360334
push id77869
push usercholler@mozilla.com
push dateMon, 11 Feb 2019 14:01:22 +0000
treeherderautoland@442a1725c992 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanerik
bugs1526328
milestone67.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 1526328 - Disable Telemetry recording in FUZZING builds. r=janerik Differential Revision: https://phabricator.services.mozilla.com/D19359
toolkit/components/telemetry/core/Telemetry.cpp
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/components/telemetry/core/Telemetry.cpp
+++ b/toolkit/components/telemetry/core/Telemetry.cpp
@@ -1101,16 +1101,19 @@ TelemetryImpl::GetCanRecordBase(bool* re
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::SetCanRecordBase(bool canRecord) {
   if (recordreplay::IsRecordingOrReplaying()) {
     return NS_OK;
   }
+#ifdef FUZZING
+  return NS_OK;
+#endif
   if (canRecord != mCanRecordBase) {
     TelemetryHistogram::SetCanRecordBase(canRecord);
     TelemetryScalar::SetCanRecordBase(canRecord);
     TelemetryEvent::SetCanRecordBase(canRecord);
     mCanRecordBase = canRecord;
   }
   return NS_OK;
 }
@@ -1128,16 +1131,19 @@ TelemetryImpl::GetCanRecordExtended(bool
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::SetCanRecordExtended(bool canRecord) {
   if (recordreplay::IsRecordingOrReplaying()) {
     return NS_OK;
   }
+#ifdef FUZZING
+  return NS_OK;
+#endif
   if (canRecord != mCanRecordExtended) {
     TelemetryHistogram::SetCanRecordExtended(canRecord);
     TelemetryScalar::SetCanRecordExtended(canRecord);
     TelemetryEvent::SetCanRecordExtended(canRecord);
     mCanRecordExtended = canRecord;
   }
   return NS_OK;
 }
@@ -1166,25 +1172,27 @@ TelemetryImpl::GetIsOfficialTelemetry(bo
 }
 
 already_AddRefed<nsITelemetry> TelemetryImpl::CreateTelemetryInstance() {
   MOZ_ASSERT(
       sTelemetry == nullptr,
       "CreateTelemetryInstance may only be called once, via GetService()");
 
   bool useTelemetry = false;
+#ifndef FUZZING
   if ((XRE_IsParentProcess() || XRE_IsContentProcess() || XRE_IsGPUProcess() ||
        XRE_IsSocketProcess()) &&
       // Telemetry is never accumulated when recording or replaying, both
       // because the resulting measurements might be biased and because
       // measurements might occur at non-deterministic points in execution
       // (e.g. garbage collections).
       !recordreplay::IsRecordingOrReplaying()) {
     useTelemetry = true;
   }
+#endif
 
   // Set current product (determines Fennec/GeckoView at runtime).
   SetCurrentProduct();
 
   // First, initialize the TelemetryHistogram and TelemetryScalar global states.
   TelemetryHistogram::InitializeGlobalState(useTelemetry, useTelemetry);
   TelemetryScalar::InitializeGlobalState(useTelemetry, useTelemetry);
 
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3831,28 +3831,31 @@ Result<bool, nsresult> XREMain::CheckLas
 int XREMain::XRE_mainStartup(bool* aExitFlag) {
   nsresult rv;
 
   if (!aExitFlag) return 1;
   *aExitFlag = false;
 
   SetShutdownChecks();
 
-  // Enable Telemetry IO Reporting on DEBUG, nightly and local builds
+  // Enable Telemetry IO Reporting on DEBUG, nightly and local builds,
+  // but disable it on FUZZING builds.
+#ifndef FUZZING
 #ifdef DEBUG
   mozilla::Telemetry::InitIOReporting(gAppData->xreDirectory);
 #else
   {
     const char* releaseChannel = NS_STRINGIFY(MOZ_UPDATE_CHANNEL);
     if (strcmp(releaseChannel, "nightly") == 0 ||
         strcmp(releaseChannel, "default") == 0) {
       mozilla::Telemetry::InitIOReporting(gAppData->xreDirectory);
     }
   }
 #endif /* DEBUG */
+#endif /* FUZZING */
 
 #if defined(XP_WIN)
   // Enable the HeapEnableTerminationOnCorruption exploit mitigation. We ignore
   // the return code because it always returns success, although it has no
   // effect on Windows older than XP SP3.
   HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
 #endif /* XP_WIN */