From caec3cc41bf3cb265800624efff14241d297f36b Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 7 May 2025 11:15:59 +0100 Subject: [PATCH] crypto: disable ASan for sha256_sse4 with Clang This can alsofail to compile when optimisations are being used, see: https://github.com/bitcoin/bitcoin/issues/31913. So disable just ASan for this function under any optimisation level. Github-Pull: #32437 Rebased-From: 4e8ab5e00fa72016a7ec0e0505ca025d4e59e4d8 --- src/crypto/sha256_sse4.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/crypto/sha256_sse4.cpp b/src/crypto/sha256_sse4.cpp index f0e255a23cb..f68e226138e 100644 --- a/src/crypto/sha256_sse4.cpp +++ b/src/crypto/sha256_sse4.cpp @@ -13,13 +13,17 @@ namespace sha256_sse4 { void Transform(uint32_t* s, const unsigned char* chunk, size_t blocks) -#if defined(__clang__) && !defined(__OPTIMIZE__) +#if defined(__clang__) /* clang is unable to compile this with -O0 and -fsanitize=address. - See upstream bug: https://github.com/llvm/llvm-project/issues/92182 + See upstream bug: https://github.com/llvm/llvm-project/issues/92182. + This also fails to compile with -O2, -fcf-protection & -fsanitize=address. + See https://github.com/bitcoin/bitcoin/issues/31913. */ +#if __has_feature(address_sanitizer) __attribute__((no_sanitize("address"))) #endif +#endif { static const uint32_t K256 alignas(16) [] = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,