From 25cc723823e3aa9bf6d7edfcd308bb82ab05b0fc Mon Sep 17 00:00:00 2001 From: Rafael Cintron Date: Fri, 23 Aug 2019 22:41:48 +0000 Subject: [PATCH] Fix mFenceEvent HANDLE leak dawn_native::d3d12::Device::mFenceEvent is created in Initialize but is never closed. Fix is to close in the destructor if it has been previously created. Bug: dawn:215 Change-Id: Ie9e7a395fe6fe791e2581295ed12f20070671afa Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10480 Commit-Queue: Kai Ninomiya Reviewed-by: Austin Eng Reviewed-by: Kai Ninomiya --- src/dawn_native/d3d12/DeviceD3D12.cpp | 4 ++++ src/dawn_native/d3d12/DeviceD3D12.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dawn_native/d3d12/DeviceD3D12.cpp b/src/dawn_native/d3d12/DeviceD3D12.cpp index f49d843c99..a0318d85be 100644 --- a/src/dawn_native/d3d12/DeviceD3D12.cpp +++ b/src/dawn_native/d3d12/DeviceD3D12.cpp @@ -120,6 +120,10 @@ namespace dawn_native { namespace d3d12 { // Call Tick() again to clear them before releasing the allocator. mResourceAllocator->Tick(mCompletedSerial); + if (mFenceEvent != nullptr) { + ::CloseHandle(mFenceEvent); + } + ASSERT(mUsedComObjectRefs.Empty()); ASSERT(mPendingCommands.commandList == nullptr); } diff --git a/src/dawn_native/d3d12/DeviceD3D12.h b/src/dawn_native/d3d12/DeviceD3D12.h index 6af417accb..e45e8116be 100644 --- a/src/dawn_native/d3d12/DeviceD3D12.h +++ b/src/dawn_native/d3d12/DeviceD3D12.h @@ -107,7 +107,7 @@ namespace dawn_native { namespace d3d12 { Serial mCompletedSerial = 0; Serial mLastSubmittedSerial = 0; ComPtr mFence; - HANDLE mFenceEvent; + HANDLE mFenceEvent = nullptr; ComPtr mD3d12Device; // Device is owned by adapter and will not be outlived. ComPtr mCommandQueue;