Skip to content

Commit

Permalink
Reland "Fix crash in DeleteGrBackendTexture"
Browse files Browse the repository at this point in the history
This is a reland of b7d7106

The original hold ref of SharedContextState, it causes the
use-after-release problem with msan bots. The new reland CL doesn't hold
the ref anymore.

Original change's description:
> Fix crash in DeleteGrBackendTexture
>
> The crash is because the gr_context_ in SharedContextState has been
> abandoned and set to nullptr.
>
> Bug: 1049580
> Change-Id: I1a179e10fc23f584b111757f3a8a049b5487ba47
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2043852
> Commit-Queue: Peng Huang <penghuang@chromium.org>
> Auto-Submit: Peng Huang <penghuang@chromium.org>
> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#739427}

Bug: 1049580
Change-Id: I1c5d2ca290b15a1112c87bc34fd7f6fd62886f34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2046713
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739904}
  • Loading branch information
phuang authored and Commit Bot committed Feb 10, 2020
1 parent 0b4f4b1 commit 8b78a1f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions gpu/command_buffer/service/skia_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ void CleanupAfterSkiaFlush(void* context) {
template <class T>
void DeleteSkObject(SharedContextState* context_state, sk_sp<T> sk_object) {
DCHECK(sk_object && sk_object->unique());

if (context_state->context_lost())
return;
DCHECK(!context_state->gr_context()->abandoned());

if (!context_state->GrContextIsVulkan())
return;

Expand Down Expand Up @@ -128,6 +133,11 @@ void AddVulkanCleanupTaskForSkiaFlush(
void DeleteGrBackendTexture(SharedContextState* context_state,
GrBackendTexture* backend_texture) {
DCHECK(backend_texture && backend_texture->isValid());

if (context_state->context_lost())
return;
DCHECK(!context_state->gr_context()->abandoned());

if (!context_state->GrContextIsVulkan()) {
context_state->gr_context()->deleteBackendTexture(
std::move(*backend_texture));
Expand All @@ -140,9 +150,8 @@ void DeleteGrBackendTexture(SharedContextState* context_state,
fence_helper->EnqueueCleanupTaskForSubmittedWork(base::BindOnce(
[](const sk_sp<GrContext>& gr_context, GrBackendTexture backend_texture,
gpu::VulkanDeviceQueue* device_queue, bool is_lost) {
// If underlying Vulkan device is destroyed, gr_context should have been
// abandoned, the deleteBackendTexture() should be noop.
gr_context->deleteBackendTexture(std::move(backend_texture));
if (!gr_context->abandoned())
gr_context->deleteBackendTexture(std::move(backend_texture));
},
sk_ref_sp(context_state->gr_context()), std::move(*backend_texture)));
#endif
Expand Down

0 comments on commit 8b78a1f

Please sign in to comment.