bug 1218576 - Ensure accumulations are for valid IDs. r=gfritzsche
authorChris H-C <chutten@mozilla.com>
Thu, 08 Sep 2016 10:09:54 -0400
changeset 314453 1b498933da3ae553f8a965c4b20e40fbe57fd1bf
parent 314452 fcfa94c81e0a437817caff6497ef2ace29b92ccb
child 314454 ca430b715311fd26c1709f9ef07ac19d741f6ca8
push id20574
push usercbook@mozilla.com
push dateTue, 20 Sep 2016 10:05:16 +0000
treeherderfx-team@14705f779a46 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1218576
milestone51.0a1
bug 1218576 - Ensure accumulations are for valid IDs. r=gfritzsche We're seeing occasional failures of the isValid assert on the parent side where the ID we're being asked to accumulate on is invalid. Check the IDs on both sides to ensure that they're valid heading in. MozReview-Commit-ID: 4gLG54Tx64s
toolkit/components/telemetry/TelemetryHistogram.cpp
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -1332,32 +1332,36 @@ internal_RemoteAccumulate(mozilla::Telem
   }
   gKeyedAccumulations->AppendElement(KeyedAccumulation{aId, aSample, aKey});
   internal_armIPCTimer();
   return true;
 }
 
 void internal_Accumulate(mozilla::Telemetry::ID aHistogram, uint32_t aSample)
 {
-  if (!internal_CanRecordBase() ||
+  bool isValid = internal_IsHistogramEnumId(aHistogram);
+  MOZ_ASSERT(isValid, "Accumulation using invalid id");
+  if (!internal_CanRecordBase() || !isValid ||
       internal_RemoteAccumulate(aHistogram, aSample)) {
     return;
   }
   Histogram *h;
   nsresult rv = internal_GetHistogramByEnumId(aHistogram, &h);
   if (NS_SUCCEEDED(rv)) {
     internal_HistogramAdd(*h, aSample, gHistograms[aHistogram].dataset);
   }
 }
 
 void
 internal_Accumulate(mozilla::Telemetry::ID aID,
                     const nsCString& aKey, uint32_t aSample)
 {
-  if (!gInitDone || !internal_CanRecordBase() ||
+  bool isValid = internal_IsHistogramEnumId(aID);
+  MOZ_ASSERT(isValid, "Child keyed telemetry accumulation using invalid id");
+  if (!gInitDone || !internal_CanRecordBase() || !isValid ||
       internal_RemoteAccumulate(aID, aKey, aSample)) {
     return;
   }
   const HistogramInfo& th = gHistograms[aID];
   KeyedHistogram* keyed
      = internal_GetKeyedHistogramById(nsDependentCString(th.id()));
   MOZ_ASSERT(keyed);
   keyed->Add(aKey, aSample);