author | dlee <dlee@mozilla.com> |
Tue, 14 May 2019 22:42:31 +0000 | |
changeset 532807 | afbe5300acca5438c03282d21fb6e74088eff4ab |
parent 532806 | cf653553acfad30ab9cc9c57b8f420768c98d997 |
child 532808 | e5c6dee921ba9731e39eb6600ac3a46bc9497cf1 |
push id | 11272 |
push user | apavel@mozilla.com |
push date | Thu, 16 May 2019 15:28:22 +0000 |
treeherder | mozilla-beta@2265bfc5920d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gcp |
bugs | 1542744, 1362761 |
milestone | 68.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
|
--- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp @@ -1,17 +1,16 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsUrlClassifierPrefixSet.h" #include "nsIUrlClassifierPrefixSet.h" -#include "crc32c.h" #include "nsCOMPtr.h" #include "nsDebug.h" #include "nsPrintfCString.h" #include "nsTArray.h" #include "nsString.h" #include "nsTArray.h" #include "nsThreadUtils.h" #include "nsNetUtil.h" @@ -30,32 +29,19 @@ static LazyLogModule gUrlClassifierPrefi #define LOG(args) \ MOZ_LOG(gUrlClassifierPrefixSetLog, mozilla::LogLevel::Debug, args) #define LOG_ENABLED() \ MOZ_LOG_TEST(gUrlClassifierPrefixSetLog, mozilla::LogLevel::Debug) NS_IMPL_ISUPPORTS(nsUrlClassifierPrefixSet, nsIUrlClassifierPrefixSet, nsIMemoryReporter) -template <typename T> -static void CalculateTArrayChecksum(const nsTArray<T>& aArray, - uint32_t* outChecksum) { - *outChecksum = ~0; - - for (size_t i = 0; i < aArray.Length(); i++) { - const T& element = aArray[i]; - const void* pointer = &element; - *outChecksum = ComputeCrc32c( - *outChecksum, reinterpret_cast<const uint8_t*>(pointer), sizeof(void*)); - } -} nsUrlClassifierPrefixSet::nsUrlClassifierPrefixSet() : mLock("nsUrlClassifierPrefixSet.mLock"), - mIndexDeltasChecksum(~0), mTotalPrefixes(0) {} NS_IMETHODIMP nsUrlClassifierPrefixSet::Init(const nsACString& aName) { mName = aName; mMemoryReportPath = nsPrintfCString( "explicit/storage/prefix-set/%s", (!aName.IsEmpty() ? PromiseFlatCString(aName).get() : "?!")); @@ -67,17 +53,16 @@ nsUrlClassifierPrefixSet::Init(const nsA nsUrlClassifierPrefixSet::~nsUrlClassifierPrefixSet() { UnregisterWeakMemoryReporter(this); } void nsUrlClassifierPrefixSet::Clear() { LOG(("[%s] Clearing PrefixSet", mName.get())); mIndexDeltas.Clear(); - mIndexDeltasChecksum = ~0; mIndexPrefixes.Clear(); mTotalPrefixes = 0; } NS_IMETHODIMP nsUrlClassifierPrefixSet::SetPrefixes(const uint32_t* aArray, uint32_t aLength) { MutexAutoLock lock(mLock); @@ -141,25 +126,21 @@ nsresult nsUrlClassifierPrefixSet::MakeP } previousItem = aPrefixes[i]; } mTotalPrefixes = aLength; mIndexDeltas.LastElement().Compact(); - // The hdr pointer of the last element of nsTArray may change after calling - // mIndexDeltas.LastElement().Compact(), so calculate checksum after the call. - CalculateTArrayChecksum(mIndexDeltas, &mIndexDeltasChecksum); - mIndexDeltas.Compact(); mIndexPrefixes.Compact(); MOZ_ASSERT(mIndexPrefixes.Length() == mIndexDeltas.Length()); - LOG(("Total number of indices: %d (crc=%u)", aLength, mIndexDeltasChecksum)); + LOG(("Total number of indices: %d", aLength)); LOG(("Total number of deltas: %d", totalDeltas)); LOG(("Total number of delta chunks: %zu", mIndexDeltas.Length())); return NS_OK; } nsresult nsUrlClassifierPrefixSet::GetPrefixesNative( FallibleTArray<uint32_t>& outArray) { @@ -438,29 +419,16 @@ uint32_t nsUrlClassifierPrefixSet::Calcu } nsresult nsUrlClassifierPrefixSet::WritePrefixes( nsCOMPtr<nsIOutputStream>& out) const { MutexAutoLock lock(mLock); mCanary.Check(); - // In Bug 1362761, crashes happened while reading mIndexDeltas[i]. - // We suspect that this is due to memory corruption so to test this - // hypothesis, we will crash the browser. Once we have established - // memory corruption as the root cause, we can attempt to gracefully - // handle this. - uint32_t checksum; - CalculateTArrayChecksum(mIndexDeltas, &checksum); - if (checksum != mIndexDeltasChecksum) { - LOG(("[%s] The contents of mIndexDeltas doesn't match the checksum!", - mName.get())); - MOZ_CRASH("Memory corruption detected in mIndexDeltas."); - } - uint32_t written; uint32_t writelen = sizeof(uint32_t); const uint32_t magic = PREFIXSET_VERSION_MAGIC; nsresult rv = out->Write(reinterpret_cast<const char*>(&magic), writelen, &written); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
--- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h +++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h @@ -72,17 +72,16 @@ class nsUrlClassifierPrefixSet final : p // list of fully stored prefixes, that also form the // start of a run of deltas in mIndexDeltas. nsTArray<uint32_t> mIndexPrefixes; // array containing arrays of deltas from indices. // Index to the place that matches the closest lower // prefix from mIndexPrefix. Then every "delta" corresponds // to a prefix in the PrefixSet. nsTArray<nsTArray<uint16_t> > mIndexDeltas; - uint32_t mIndexDeltasChecksum; // how many prefixes we have. uint32_t mTotalPrefixes; nsCString mName; nsCString mMemoryReportPath; mozilla::CorruptionCanary mCanary; };