From 3542af208598b2a6ada9e0f4557cf4660799b3fd Mon Sep 17 00:00:00 2001 From: Tacet <4922191+AdvenamTacet@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:24:10 +0200 Subject: [PATCH] [ASan][libc++] Turn off SSO annotations for Apple platforms (#96269) This commit disables short string AddressSanitizer annotations on Apple platforms as a temporary solution to the problem reported in #96099. For more information on Apple's block implementation, please refer to clang/docs/Block-ABI-Apple.rst [1]. The core issue lies in the fact that blocks are unaware of their content, causing AddressSanitizer errors when blocks are moved using `memmove`. I believe - and I'm not alone - that the issue should ideally be addressed within the block moving logic. However, this patch provides a temporary fix until a proper resolution exists in the Blocks runtime. [1]: https://github.com/llvm/llvm-project/blob/main/clang/docs/Block-ABI-Apple.rst --- libcxx/include/string | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libcxx/include/string b/libcxx/include/string index 54e9d8990c2204..2fd1b1e745908c 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1983,6 +1983,11 @@ private: (void)__old_mid; (void)__new_mid; #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) + #if defined(__APPLE__) + // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) + if(!__is_long()) + return; + #endif std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid); #endif }