From f10922a8fa84d332a4d001bc2a1f659a00ae0213 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Fri, 13 Jan 2023 11:51:59 -0500 Subject: [PATCH 1/2] Disable Custom ASAN/MSAN Poisoning on MinGW Builds Addresses #3240. --- lib/common/compiler.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/common/compiler.h b/lib/common/compiler.h index e423f2467..4ad55e601 100644 --- a/lib/common/compiler.h +++ b/lib/common/compiler.h @@ -281,6 +281,17 @@ * Sanitizer *****************************************************************/ +/* Issue #3240 reports an ASAN failure on an llvm-mingw build. Out of an + * abundance of caution, disable our custom poisoning on mingw. */ +#ifdef __MINGW32__ +#ifndef ZSTD_ASAN_DONT_POISON_WORKSPACE +#define ZSTD_ASAN_DONT_POISON_WORKSPACE 1 +#endif +#ifndef ZSTD_MSAN_DONT_POISON_WORKSPACE +#define ZSTD_MSAN_DONT_POISON_WORKSPACE 1 +#endif +#endif + #if ZSTD_MEMORY_SANITIZER /* Not all platforms that support msan provide sanitizers/msan_interface.h. * We therefore declare the functions we need ourselves, rather than trying to From d78fbedd968988270c27c215ae5f592990f0bc1d Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Fri, 13 Jan 2023 11:56:48 -0500 Subject: [PATCH 2/2] Don't Even Declare Poisoning Functions if Poisoning is Disabled This guarantees that we won't accidentally forget to check the macro somewhere where we use these functions. --- lib/common/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/compiler.h b/lib/common/compiler.h index 4ad55e601..d4f2f285d 100644 --- a/lib/common/compiler.h +++ b/lib/common/compiler.h @@ -292,7 +292,7 @@ #endif #endif -#if ZSTD_MEMORY_SANITIZER +#if ZSTD_MEMORY_SANITIZER && !defined(ZSTD_MSAN_DONT_POISON_WORKSPACE) /* Not all platforms that support msan provide sanitizers/msan_interface.h. * We therefore declare the functions we need ourselves, rather than trying to * include the header file... */ @@ -313,7 +313,7 @@ void __msan_poison(const volatile void *a, size_t size); intptr_t __msan_test_shadow(const volatile void *x, size_t size); #endif -#if ZSTD_ADDRESS_SANITIZER +#if ZSTD_ADDRESS_SANITIZER && !defined(ZSTD_ASAN_DONT_POISON_WORKSPACE) /* Not all platforms that support asan provide sanitizers/asan_interface.h. * We therefore declare the functions we need ourselves, rather than trying to * include the header file... */