Backed out changeset 996f931d61b6 (bug 1605478) for build bustages in Unified_cpp_toolkit_xre0.obj
authorOana Pop Rus <opoprus@mozilla.com>
Sun, 08 Mar 2020 16:40:06 +0200
changeset 517471 6b1d5e72a65b5d97025a566196fa5cb63b7e4549
parent 517470 da252eb0ae61dfd0f8aaa4ca6794a6fdc7de2f35
child 517474 615bbb98f5bad4a4ecd6a22d671e727ee7a9bf13
push id37192
push useropoprus@mozilla.com
push dateSun, 08 Mar 2020 14:42:14 +0000
treeherdermozilla-central@6b1d5e72a65b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1605478
milestone75.0a1
backs out996f931d61b64a1cc731a8402587db9a54600c5e
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
Backed out changeset 996f931d61b6 (bug 1605478) for build bustages in Unified_cpp_toolkit_xre0.obj
toolkit/xre/UntrustedModulesData.cpp
toolkit/xre/UntrustedModulesData.h
toolkit/xre/UntrustedModulesProcessor.cpp
--- a/toolkit/xre/UntrustedModulesData.cpp
+++ b/toolkit/xre/UntrustedModulesData.cpp
@@ -8,17 +8,16 @@
 
 #include <windows.h>
 
 #include "mozilla/CmdLineAndEnvUtils.h"
 #include "mozilla/DynamicallyLinkedFunctionPtr.h"
 #include "mozilla/FileUtilsWin.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MathAlgorithms.h"
-#include "mozilla/RandomNum.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Unused.h"
 #include "mozilla/WinDllServices.h"
 #include "ModuleEvaluator.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsXULAppAPI.h"
 #include "WinUtils.h"
@@ -297,45 +296,16 @@ bool ProcessedModuleLoadEvent::IsXULLoad
 bool ProcessedModuleLoadEvent::IsTrusted() const {
   if (!mModule) {
     return false;
   }
 
   return mModule->IsTrusted();
 }
 
-void UntrustedModulesData::VerifyConsistency() const {
-  if (!mIsDiagnosticsAssertEnabled) {
-    return;
-  }
-
-  for (auto& evt : mEvents) {
-    MOZ_DIAGNOSTIC_ASSERT(evt.mModule, "Empty module");
-    MOZ_DIAGNOSTIC_ASSERT(!evt.mModule->mResolvedNtName.IsEmpty(),
-                          "Empty mResolvedNtName");
-    MOZ_DIAGNOSTIC_ASSERT(mModules.Get(evt.mModule->mResolvedNtName, nullptr),
-                          "No match in the table");
-  }
-}
-
-/* static */
-bool UntrustedModulesData::IsDiagnosticsAssertEnabled() {
-#ifdef NIGHTLY_BUILD
-  // Trigger MOZ_DIAGNOSTIC_ASSERT with a probability of 1/16
-  constexpr double kDiagnosticsAssertRatio = 0.0625;
-
-  constexpr uint64_t kBoundary =
-      std::numeric_limits<uint64_t>::max() * kDiagnosticsAssertRatio;
-  Maybe<uint64_t> randomNum = RandomUint64();
-  return randomNum.isSome() && randomNum.value() <= kBoundary;
-#else
-  return false;
-#endif
-}
-
 void UntrustedModulesData::AddNewLoads(
     const ModulesMap& aModules, Vector<ProcessedModuleLoadEvent>&& aEvents,
     Vector<Telemetry::ProcessedStack>&& aStacks) {
   MOZ_ASSERT(aEvents.length() == aStacks.length());
 
   for (auto iter = aModules.ConstIter(); !iter.Done(); iter.Next()) {
     if (iter.Data()->IsTrusted()) {
       // Filter out trusted module records
@@ -344,19 +314,16 @@ void UntrustedModulesData::AddNewLoads(
 
     auto addPtr = mModules.LookupForAdd(iter.Key());
     if (addPtr) {
       // |mModules| already contains this record
       continue;
     }
 
     RefPtr<ModuleRecord> rec(iter.Data());
-    if (mIsDiagnosticsAssertEnabled) {
-      MOZ_DIAGNOSTIC_ASSERT(rec->mResolvedNtName == iter.Key());
-    }
     addPtr.OrInsert([rec = std::move(rec)]() { return rec; });
   }
 
   // This constant matches the maximum in Telemetry::CombinedStacks
   const size_t kMaxEvents = 50;
   MOZ_ASSERT(mEvents.length() <= kMaxEvents);
 
   if (mEvents.length() + aEvents.length() > kMaxEvents) {
--- a/toolkit/xre/UntrustedModulesData.h
+++ b/toolkit/xre/UntrustedModulesData.h
@@ -166,18 +166,17 @@ class ModulesMap final
 };
 
 class UntrustedModulesData final {
  public:
   UntrustedModulesData()
       : mProcessType(XRE_GetProcessType()),
         mPid(::GetCurrentProcessId()),
         mSanitizationFailures(0),
-        mTrustTestFailures(0),
-        mIsDiagnosticsAssertEnabled(IsDiagnosticsAssertEnabled()) {}
+        mTrustTestFailures(0) {}
 
   UntrustedModulesData(UntrustedModulesData&&) = default;
   UntrustedModulesData& operator=(UntrustedModulesData&&) = default;
 
   UntrustedModulesData(const UntrustedModulesData&) = delete;
   UntrustedModulesData& operator=(const UntrustedModulesData&) = delete;
 
   explicit operator bool() const {
@@ -186,32 +185,25 @@ class UntrustedModulesData final {
   }
 
   void AddNewLoads(const ModulesMap& aModulesMap,
                    Vector<ProcessedModuleLoadEvent>&& aEvents,
                    Vector<Telemetry::ProcessedStack>&& aStacks);
 
   void Swap(UntrustedModulesData& aOther);
 
-  void VerifyConsistency() const;
-  static bool IsDiagnosticsAssertEnabled();
-
   GeckoProcessType mProcessType;
   DWORD mPid;
   TimeDuration mElapsed;
   ModulesMap mModules;
   Vector<ProcessedModuleLoadEvent> mEvents;
   Telemetry::CombinedStacks mStacks;
   Maybe<double> mXULLoadDurationMS;
   uint32_t mSanitizationFailures;
   uint32_t mTrustTestFailures;
-
-  // This is not serialized.
-  // Cannot be const as we have the default move ctor.
-  bool mIsDiagnosticsAssertEnabled;
 };
 
 class ModulesMapResult final {
  public:
   ModulesMapResult() : mTrustTestFailures(0) {}
 
   ModulesMapResult(const ModulesMapResult& aOther) = delete;
   ModulesMapResult(ModulesMapResult&& aOther) = default;
@@ -429,18 +421,16 @@ struct ParamTraits<mozilla::ModulePaths>
   }
 };
 
 template <>
 struct ParamTraits<mozilla::UntrustedModulesData> {
   typedef mozilla::UntrustedModulesData paramType;
 
   static void Write(Message* aMsg, const paramType& aParam) {
-    aParam.VerifyConsistency();
-
     aMsg->WriteUInt32(aParam.mProcessType);
     aMsg->WriteULong(aParam.mPid);
     WriteParam(aMsg, aParam.mElapsed);
     WriteParam(aMsg, aParam.mModules);
 
     aMsg->WriteUInt32(aParam.mEvents.length());
     for (auto& evt : aParam.mEvents) {
       WriteEvent(aMsg, evt);
@@ -480,17 +470,17 @@ struct ParamTraits<mozilla::UntrustedMod
     }
 
     if (!aResult->mEvents.resize(eventsLen)) {
       return false;
     }
 
     for (uint32_t curEventIdx = 0; curEventIdx < eventsLen; ++curEventIdx) {
       if (!ReadEvent(aMsg, aIter, &(aResult->mEvents[curEventIdx]),
-                     aResult->mModules, aResult->mIsDiagnosticsAssertEnabled)) {
+                     aResult->mModules)) {
         return false;
       }
     }
 
     if (!ReadParam(aMsg, aIter, &aResult->mStacks)) {
       return false;
     }
 
@@ -528,18 +518,17 @@ struct ParamTraits<mozilla::UntrustedMod
     WriteParam(aMsg, aParam.mModule->mResolvedNtName);
   }
 
   // Because ProcessedModuleLoadEvent depends on a hash table from
   // UntrustedModulesData, we do its deserialization as part of this
   // specialization.
   static bool ReadEvent(const Message* aMsg, PickleIterator* aIter,
                         mozilla::ProcessedModuleLoadEvent* aResult,
-                        const mozilla::ModulesMap& aModulesMap,
-                        bool aIsDiagnosticsAssertEnabled) {
+                        const mozilla::ModulesMap& aModulesMap) {
     if (!aMsg->ReadUInt64(aIter, &aResult->mProcessUptimeMS)) {
       return false;
     }
 
     if (!ReadParam(aMsg, aIter, &aResult->mLoadDurationMS)) {
       return false;
     }
 
@@ -564,21 +553,16 @@ struct ParamTraits<mozilla::UntrustedMod
       return false;
     }
 
     // NB: While bad data integrity might for some reason result in a null
     // mModule, we do not fail the deserialization; this is a data error,
     // rather than an IPC error. The error is detected and dealt with in
     // telemetry.
     aResult->mModule = aModulesMap.Get(resolvedNtName);
-    if (!aResult->mModule && aIsDiagnosticsAssertEnabled) {
-      MOZ_DIAGNOSTIC_ASSERT(aModulesMap.Count() > 0, "Empty module list");
-      MOZ_DIAGNOSTIC_ASSERT(!resolvedNtName.IsEmpty(), "Empty resolvedNtName");
-      MOZ_DIAGNOSTIC_ASSERT(false, "Something else");
-    }
 
     return true;
   }
 };
 
 template <>
 struct ParamTraits<mozilla::ModulesMapResult> {
   typedef mozilla::ModulesMapResult paramType;
--- a/toolkit/xre/UntrustedModulesProcessor.cpp
+++ b/toolkit/xre/UntrustedModulesProcessor.cpp
@@ -376,18 +376,16 @@ RefPtr<UntrustedModulesPromise> Untruste
   if (!mProcessedModuleLoads) {
     return UntrustedModulesPromise::CreateAndResolve(Nothing(), aSource);
   }
 
   result.Swap(mProcessedModuleLoads);
 
   result.mElapsed = TimeStamp::Now() - TimeStamp::ProcessCreation();
 
-  result.VerifyConsistency();
-
   return UntrustedModulesPromise::CreateAndResolve(
       Some(UntrustedModulesData(std::move(result))), aSource);
 }
 
 RefPtr<UntrustedModulesPromise>
 UntrustedModulesProcessor::GetProcessedDataInternalChildProcess() {
   AssertRunningOnLazyIdleThread();
   MOZ_ASSERT(!XRE_IsParentProcess());
@@ -872,22 +870,16 @@ void UntrustedModulesProcessor::Complete
         // continue.
         continue;
       }
 
       if (!mAllowProcessing) {
         return;
       }
 
-      // Trusted modules should have been eliminated by GetModulesTrustInternal
-      // in the browser process
-      if (mProcessedModuleLoads.mIsDiagnosticsAssertEnabled) {
-        MOZ_DIAGNOSTIC_ASSERT(!event.IsTrusted());
-      }
-
       Telemetry::ProcessedStack processedStack =
           stackProcessor.GetStackAndModules(backtrace);
 
       Unused << processedStacks.emplaceBack(std::move(processedStack));
       Unused << processedEvents.emplaceBack(std::move(event));
     }
   }
 
@@ -898,19 +890,16 @@ void UntrustedModulesProcessor::Complete
   }
 
   if (!mAllowProcessing) {
     return;
   }
 
   mProcessedModuleLoads.AddNewLoads(modules, std::move(processedEvents),
                                     std::move(processedStacks));
-
-  mProcessedModuleLoads.VerifyConsistency();
-
   if (maybeXulLoadDuration) {
     MOZ_ASSERT(!mProcessedModuleLoads.mXULLoadDurationMS);
     mProcessedModuleLoads.mXULLoadDurationMS = maybeXulLoadDuration;
   }
 
   mProcessedModuleLoads.mSanitizationFailures += sanitizationFailures;
   mProcessedModuleLoads.mTrustTestFailures += trustTestFailures;
 }