Commit 1709ec5f authored by Ben Kelly's avatar Ben Kelly Committed by Commit Bot

CacheStorage: Fix flaky crashes with DCHECK enabled.

The cache-add.https.html WPT tests became flaky after landing
crrev.com/c/2429308.  The flakes were due to crashes accessing a vector
element beyond its length.  I believe this is due to:

  DCHECK(!blob_list_[index]);

Which is performed before we check to see if we are already stopped.
Since we clear this vector when stopped this DCHECK will crash if a
completion comes in right after aborting.

This CL moves the DCHECKs below our stopped check.  It also explicitly
sets the stopped state when successfully complete as well.

Bug: 1134021,1130781
Change-Id: I075f2daca252ac78a93d5e3991f44389adcf9689
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443069Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812766}
parent 68d98381
......@@ -205,13 +205,13 @@ class Cache::BarrierCallbackForPutResponse final
void CompletedResponse(int index,
Response* response,
scoped_refptr<BlobDataHandle> blob) {
if (stopped_)
return;
DCHECK(!response_list_[index]);
DCHECK(!blob_list_[index]);
DCHECK_LT(num_complete_, request_list_.size());
if (stopped_)
return;
response_list_[index] = response;
blob_list_[index] = std::move(blob);
num_complete_ += 1;
......@@ -223,6 +223,7 @@ class Cache::BarrierCallbackForPutResponse final
cache_->PutImpl(resolver_, method_name_, request_list_, response_list_,
blob_list_, exception_state, trace_id_);
blob_list_.clear();
stopped_ = true;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment