From b11bd2dfe513ea4dc912465250df62c0c219c4d0 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Wed, 18 Sep 2019 21:03:41 +0000 Subject: [PATCH] Fix leak of ErrorData after Device::ConsumedError The code to delete this ErrorData* was lost in the error scope refactor. Bug: chromium:1002783, chromium:1002888, dawn:153 Change-Id: Iebe13c778079501193b942ebd97a559041516c3d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11320 Reviewed-by: Corentin Wallez Reviewed-by: Kai Ninomiya Commit-Queue: Austin Eng --- src/dawn_native/Device.cpp | 6 ++++-- src/dawn_native/Device.h | 5 +++-- src/dawn_native/ErrorScope.cpp | 6 ------ src/dawn_native/ErrorScope.h | 3 --- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index fa450631f5..7bc8011c02 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -98,8 +98,10 @@ namespace dawn_native { mCurrentErrorScope->HandleError(type, message); } - void DeviceBase::HandleError(ErrorData* data) { - mCurrentErrorScope->HandleError(data); + void DeviceBase::ConsumeError(ErrorData* error) { + ASSERT(error != nullptr); + HandleError(error->GetType(), error->GetMessage().c_str()); + delete error; } void DeviceBase::SetUncapturedErrorCallback(dawn::ErrorCallback callback, void* userdata) { diff --git a/src/dawn_native/Device.h b/src/dawn_native/Device.h index 1c3354f4c7..cf69282376 100644 --- a/src/dawn_native/Device.h +++ b/src/dawn_native/Device.h @@ -47,11 +47,10 @@ namespace dawn_native { virtual ~DeviceBase(); void HandleError(dawn::ErrorType type, const char* message); - void HandleError(ErrorData* error); bool ConsumedError(MaybeError maybeError) { if (DAWN_UNLIKELY(maybeError.IsError())) { - HandleError(maybeError.AcquireError()); + ConsumeError(maybeError.AcquireError()); return true; } return false; @@ -237,6 +236,8 @@ namespace dawn_native { void SetDefaultToggles(); + void ConsumeError(ErrorData* error); + AdapterBase* mAdapter = nullptr; Ref mRootErrorScope; diff --git a/src/dawn_native/ErrorScope.cpp b/src/dawn_native/ErrorScope.cpp index 812ab69433..1758ef71b3 100644 --- a/src/dawn_native/ErrorScope.cpp +++ b/src/dawn_native/ErrorScope.cpp @@ -15,7 +15,6 @@ #include "dawn_native/ErrorScope.h" #include "common/Assert.h" -#include "dawn_native/ErrorData.h" namespace dawn_native { @@ -50,11 +49,6 @@ namespace dawn_native { HandleErrorImpl(this, type, message); } - void ErrorScope::HandleError(ErrorData* error) { - ASSERT(error != nullptr); - HandleErrorImpl(this, error->GetType(), error->GetMessage().c_str()); - } - // static void ErrorScope::HandleErrorImpl(ErrorScope* scope, dawn::ErrorType type, const char* message) { ErrorScope* currentScope = scope; diff --git a/src/dawn_native/ErrorScope.h b/src/dawn_native/ErrorScope.h index 9bafcf9474..f3218cb41e 100644 --- a/src/dawn_native/ErrorScope.h +++ b/src/dawn_native/ErrorScope.h @@ -23,8 +23,6 @@ namespace dawn_native { - class ErrorData; - // Errors can be recorded into an ErrorScope by calling |HandleError|. // Because an error scope should not resolve until contained // commands are complete, calling the callback is deferred until it is destructed. @@ -47,7 +45,6 @@ namespace dawn_native { ErrorScope* GetParent(); void HandleError(dawn::ErrorType type, const char* message); - void HandleError(ErrorData* error); void Destroy();