Commit 3f8e7a2a authored by dmurph's avatar dmurph Committed by Commit bot

[Blob] Removed crash on race case blob messages

We have substantial crashes since adding bad_message errors for invalid
blob messages. It looks like there is a pre-existing condition where
blob references are race casing across processes.

While we investigate the issue, we want to remove this crash so it's not
making the situation worse (crashing instead of having a broken blob).

I'm keeping the uuid.empty() condition as a bad message, because that's
definitely an error that shouldn't be happening.

BUG=606065

Review URL: https://codereview.chromium.org/1913343002

Cr-Commit-Position: refs/heads/master@{#389868}
parent 47efd876
...@@ -219,26 +219,32 @@ void BlobDispatcherHost::OnCancelBuildingBlob( ...@@ -219,26 +219,32 @@ void BlobDispatcherHost::OnCancelBuildingBlob(
void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) { void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
BlobStorageContext* context = this->context(); BlobStorageContext* context = this->context();
if (uuid.empty() || !context->registry().HasEntry(uuid)) { if (uuid.empty()) {
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidReference", BDH_INCREMENT,
BDH_TRACING_ENUM_LAST);
bad_message::ReceivedBadMessage( bad_message::ReceivedBadMessage(
this, bad_message::BDH_INVALID_REFCOUNT_OPERATION); this, bad_message::BDH_INVALID_REFCOUNT_OPERATION);
return; return;
} }
if (!context->registry().HasEntry(uuid)) {
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidReference", BDH_INCREMENT,
BDH_TRACING_ENUM_LAST);
return;
}
context->IncrementBlobRefCount(uuid); context->IncrementBlobRefCount(uuid);
blobs_inuse_map_[uuid] += 1; blobs_inuse_map_[uuid] += 1;
} }
void BlobDispatcherHost::OnDecrementBlobRefCount(const std::string& uuid) { void BlobDispatcherHost::OnDecrementBlobRefCount(const std::string& uuid) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (uuid.empty() || !IsInUseInHost(uuid)) { if (uuid.empty()) {
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidReference", BDH_DECREMENT,
BDH_TRACING_ENUM_LAST);
bad_message::ReceivedBadMessage( bad_message::ReceivedBadMessage(
this, bad_message::BDH_INVALID_REFCOUNT_OPERATION); this, bad_message::BDH_INVALID_REFCOUNT_OPERATION);
return; return;
} }
if (!IsInUseInHost(uuid)) {
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidReference", BDH_DECREMENT,
BDH_TRACING_ENUM_LAST);
return;
}
BlobStorageContext* context = this->context(); BlobStorageContext* context = this->context();
context->DecrementBlobRefCount(uuid); context->DecrementBlobRefCount(uuid);
blobs_inuse_map_[uuid] -= 1; blobs_inuse_map_[uuid] -= 1;
...@@ -262,25 +268,30 @@ void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url, ...@@ -262,25 +268,30 @@ void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url,
const std::string& uuid) { const std::string& uuid) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
BlobStorageContext* context = this->context(); BlobStorageContext* context = this->context();
if (uuid.empty() || !IsInUseInHost(uuid) || if (uuid.empty()) {
context->registry().IsURLMapped(public_url)) {
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidURLRegister", BDH_INCREMENT,
BDH_TRACING_ENUM_LAST);
bad_message::ReceivedBadMessage(this, bad_message::ReceivedBadMessage(this,
bad_message::BDH_INVALID_URL_OPERATION); bad_message::BDH_INVALID_URL_OPERATION);
return; return;
} }
if (!IsInUseInHost(uuid) || context->registry().IsURLMapped(public_url)) {
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidURLRegister", BDH_INCREMENT,
BDH_TRACING_ENUM_LAST);
return;
}
context->RegisterPublicBlobURL(public_url, uuid); context->RegisterPublicBlobURL(public_url, uuid);
public_blob_urls_.insert(public_url); public_blob_urls_.insert(public_url);
} }
void BlobDispatcherHost::OnRevokePublicBlobURL(const GURL& public_url) { void BlobDispatcherHost::OnRevokePublicBlobURL(const GURL& public_url) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!public_url.is_valid()) {
bad_message::ReceivedBadMessage(this,
bad_message::BDH_INVALID_URL_OPERATION);
return;
}
if (!IsUrlRegisteredInHost(public_url)) { if (!IsUrlRegisteredInHost(public_url)) {
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidURLRegister", BDH_DECREMENT, UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidURLRegister", BDH_DECREMENT,
BDH_TRACING_ENUM_LAST); BDH_TRACING_ENUM_LAST);
bad_message::ReceivedBadMessage(this,
bad_message::BDH_INVALID_URL_OPERATION);
return; return;
} }
context()->RevokePublicBlobURL(public_url); context()->RevokePublicBlobURL(public_url);
......
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