[libcxx-commits] [libcxx] [ASan][libc++] Turn off SSO annotations for Apple platforms (PR #96269)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 20 19:40:38 PDT 2024


https://github.com/AdvenamTacet updated https://github.com/llvm/llvm-project/pull/96269

>From de2376e8340ebfc63f171d0956e2564866ea0c8d Mon Sep 17 00:00:00 2001
From: Advenam Tacet <advenam.tacet at trailofbits.com>
Date: Fri, 21 Jun 2024 04:28:56 +0200
Subject: [PATCH 1/2] [ASan][libc++] Turn off SSO annotations for Apple
 platforms

This commit disables short string AddressSanitizer annotations on Apple platforms as a temporary solution to the problem reported in issue #96099.

For more information on Apple's block implementation, please refer to [`clang/docs/Block-ABI-Apple.rst`](/clang/docs/Block-ABI-Apple.rst). 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, if a timely resolution is not feasible, this temporary fix can be used. Before merging, we should ensure that a more permanent solution cannot be implemented in time and that this change effectively resolves the issue.
---
 libcxx/include/string | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libcxx/include/string b/libcxx/include/string
index 56307b391a3e5..6b442c51c607f 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1930,6 +1930,10 @@ private:
     (void)__old_mid;
     (void)__new_mid;
 #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
+  #if defined(__APPLE__)
+    if(!__is_long())
+      return;
+  #endif
     std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid);
 #endif
   }

>From f153545012895e9d3f3b66d43a34d53b88ec860b Mon Sep 17 00:00:00 2001
From: Advenam Tacet <advenam.tacet at trailofbits.com>
Date: Fri, 21 Jun 2024 04:40:25 +0200
Subject: [PATCH 2/2] Add TODO

This solution is temporary, a new comment reflects it.
---
 libcxx/include/string | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcxx/include/string b/libcxx/include/string
index 6b442c51c607f..a4b766a6f4f22 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1931,6 +1931,7 @@ private:
     (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



More information about the libcxx-commits mailing list