Skip to content

Commit

Permalink
Early terminate GetBucketContents if WaitForCmd fails
Browse files Browse the repository at this point in the history
This should avoid the scenario outlined in crbug.com/1371859 where the
command isn't run due to the GPU process shutting down, but the memcpy
is attempted anyway.

Bug: 1371859
Change-Id: Ib2a4b735365f29d092be8003ba668854be1d5c3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4076865
Reviewed-by: Victor Miura <vmiura@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1078779}
  • Loading branch information
toji authored and Chromium LUCI CQ committed Dec 2, 2022
1 parent 180c739 commit 4af6ef2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions gpu/command_buffer/client/implementation_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ gpu::ContextResult ImplementationBase::Initialize(
return gpu::ContextResult::kSuccess;
}

void ImplementationBase::WaitForCmd() {
bool ImplementationBase::WaitForCmd() {
TRACE_EVENT0("gpu", "ImplementationBase::WaitForCmd");
helper_->Finish();
return helper_->Finish();
}

int32_t ImplementationBase::GetResultShmId() {
Expand Down Expand Up @@ -301,7 +301,9 @@ bool ImplementationBase::GetBucketContents(uint32_t bucket_id,
}
helper_->GetBucketData(bucket_id, offset, buffer.size(),
buffer.shm_id(), buffer.offset());
WaitForCmd();
if (!WaitForCmd()) {
return false;
}
}
uint32_t size_to_copy = std::min(size, buffer.size());
memcpy(&(*data)[offset], buffer.address(), size_to_copy);
Expand Down
2 changes: 1 addition & 1 deletion gpu/command_buffer/client/implementation_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class GLES2_IMPL_EXPORT ImplementationBase
gpu::ContextResult Initialize(const SharedMemoryLimits& limits);

// Waits for all commands to execute.
void WaitForCmd();
bool WaitForCmd();

// Gets the value of the result.
template <typename T>
Expand Down

0 comments on commit 4af6ef2

Please sign in to comment.