Merge mozilla-central to autoland on a CLOSED TREE
authorOana Pop Rus <opoprus@mozilla.com>
Sun, 08 Mar 2020 16:46:13 +0200
changeset 517474 615bbb98f5bad4a4ecd6a22d671e727ee7a9bf13
parent 517473 e4e54d9013a03e47dc9ca0e70c78106d7aeb88cf (current diff)
parent 517471 6b1d5e72a65b5d97025a566196fa5cb63b7e4549 (diff)
child 517475 25beb671c14a2cf8f3e4f7e7d74755353b268acf
push id37193
push usershindli@mozilla.com
push dateSun, 08 Mar 2020 21:41:29 +0000
treeherdermozilla-central@7aa696aefc46 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone75.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
Merge mozilla-central to autoland on a CLOSED TREE
--- 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;
 }