Bug 1542744 - P1. Remove calculating checksum for mIndexDelta array. r=gcp
The checksum calculating code is used to find the root cause of a crash
bug during update(Bug 1362761). Since the algorithm will be update in
these series of patches, we don't need to keep it.
Differential Revision: https://phabricator.services.mozilla.com/D26667
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "nsUrlClassifierPrefixSet.h"
|
||||
#include "nsIUrlClassifierPrefixSet.h"
|
||||
#include "crc32c.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsPrintfCString.h"
|
||||
@@ -35,22 +34,9 @@ static LazyLogModule gUrlClassifierPrefixSetLog("UrlClassifierPrefixSet");
|
||||
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
|
||||
@@ -72,7 +58,6 @@ nsUrlClassifierPrefixSet::~nsUrlClassifierPrefixSet() {
|
||||
void nsUrlClassifierPrefixSet::Clear() {
|
||||
LOG(("[%s] Clearing PrefixSet", mName.get()));
|
||||
mIndexDeltas.Clear();
|
||||
mIndexDeltasChecksum = ~0;
|
||||
mIndexPrefixes.Clear();
|
||||
mTotalPrefixes = 0;
|
||||
}
|
||||
@@ -146,15 +131,11 @@ nsresult nsUrlClassifierPrefixSet::MakePrefixSet(const uint32_t* aPrefixes,
|
||||
|
||||
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()));
|
||||
|
||||
@@ -443,19 +424,6 @@ nsresult nsUrlClassifierPrefixSet::WritePrefixes(
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user