From ac6bd4c98fc1ee386a728a1eec92075e5236a355 Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Tue, 16 Jun 2020 16:55:38 +0000 Subject: [PATCH] Fix fuzzer hang when waiting for fence signal after device loss When the fuzzer passes the command DeviceLoseForTesting, the DawnWireServerFuzzer will hang forever when waiting for a fence signal because the device was lost. This commit sets a callback on device loss which gives an extra condition to break the hang. Bug: dawn:444 Change-Id: I0157358ed6da39cc6fcab7e1be8a3d5fde74266f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23141 Reviewed-by: Corentin Wallez Reviewed-by: Natasha Lee Commit-Queue: Brandon Jones --- src/fuzzers/DawnWireServerFuzzer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/fuzzers/DawnWireServerFuzzer.cpp b/src/fuzzers/DawnWireServerFuzzer.cpp index 81be868d05..1a70f18602 100644 --- a/src/fuzzers/DawnWireServerFuzzer.cpp +++ b/src/fuzzers/DawnWireServerFuzzer.cpp @@ -50,6 +50,8 @@ namespace { std::string sInjectedErrorTestcaseOutDir; uint64_t sOutputFileNumber = 0; + bool sCommandsComplete = false; + WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, const WGPUSwapChainDescriptor*) { @@ -59,6 +61,10 @@ namespace { return sOriginalDeviceCreateSwapChain(device, surface, &desc); } + void CommandsCompleteCallback(WGPUFenceCompletionStatus status, void* userdata) { + sCommandsComplete = true; + } + } // namespace int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) { @@ -156,7 +162,8 @@ int DawnWireServerFuzzer::Run(const uint8_t* data, wgpu::Queue queue = device.GetDefaultQueue(); wgpu::Fence fence = queue.CreateFence(); queue.Signal(fence, 1u); - while (fence.GetCompletedValue() != 1u) { + fence.OnCompletion(1u, CommandsCompleteCallback, 0); + while (!sCommandsComplete) { device.Tick(); utils::USleep(100); }