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;