From bacf44f9649f0a2f2af0a76f6201386684d0c7d3 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Tue, 18 Apr 2023 20:10:51 +0000 Subject: [PATCH] Workaround dawn_wire_server_and_frontend_fuzzer ASAN false positive When discovering Vulkan adapters, if none is found, the vulkan loader DLL is loaded and then unloaded, which results in ASAN false positives when the loader's previously allocated memory is re-used, which happens in fuzzer::TracePC::ClearInlineCounters. Bug: chromium:1427723 Bug: chromium:1038952 Change-Id: Idb205607426a0af22daba363e2679afaa33204b9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127840 Reviewed-by: Austin Eng Kokoro: Kokoro Commit-Queue: Antonio Maiorano --- src/dawn/fuzzers/DawnWireServerFuzzer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/dawn/fuzzers/DawnWireServerFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp index ae2bb91860..d1c1f2c6c5 100644 --- a/src/dawn/fuzzers/DawnWireServerFuzzer.cpp +++ b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp @@ -19,6 +19,7 @@ #include #include "dawn/common/Assert.h" +#include "dawn/common/DynamicLib.h" #include "dawn/common/Log.h" #include "dawn/common/SystemUtils.h" #include "dawn/dawn_proc.h" @@ -49,6 +50,9 @@ class DevNull : public dawn::wire::CommandSerializer { std::unique_ptr sInstance; static bool (*sAdapterSupported)(const dawn::native::Adapter&) = nullptr; +#if DAWN_PLATFORM_IS(WINDOWS) && defined(ADDRESS_SANITIZER) +static DynamicLib sVulkanLoader; +#endif } // namespace @@ -57,6 +61,15 @@ int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) { // Swiftshader crashes libFuzzer. When this is fixed, move this into Run so that error injection // for adapter discovery can be fuzzed. sInstance = std::make_unique(); + + // TODO(crbug.com/1038952): Although we keep a static instance, when discovering default Vulkan + // adapters, if no adapter is found, the vulkan loader DLL will be loaded and then unloaded, + // resulting in ASAN false positives. We work around this by explicitly loading the loader + // without unloading it here. +#if DAWN_PLATFORM_IS(WINDOWS) && defined(ADDRESS_SANITIZER) + sVulkanLoader.Open(GetExecutableDirectory().value_or("") + "vulkan-1.dll"); +#endif + sInstance->DiscoverDefaultAdapters(); return 0;