[compiler-rt] [asan][test] Fix Posix/new_array_cookie_with_new_from_class.cpp to work for arm targets (PR #208378)
Ian Anderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 8 22:19:08 PDT 2026
https://github.com/ian-twilightcoder created https://github.com/llvm/llvm-project/pull/208378
arm targets and arm64 targets on Darwin use a 2-pointer array cookie size. Update the test to support that.
Assisted-by: Claude Code
rdar://181775880
>From 17dcbdc18741e1ce5c092cda9518968de47595e6 Mon Sep 17 00:00:00 2001
From: Ian Anderson <iana at apple.com>
Date: Wed, 8 Jul 2026 22:12:23 -0700
Subject: [PATCH] [asan][test] Fix
Posix/new_array_cookie_with_new_from_class.cpp to work for arm targets
arm targets and arm64 targets on Darwin use a 2-pointer array cookie size. Update the test to support that.
Assisted-by: Claude Code
rdar://181775880
---
.../Posix/new_array_cookie_with_new_from_class.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/test/asan/TestCases/Posix/new_array_cookie_with_new_from_class.cpp b/compiler-rt/test/asan/TestCases/Posix/new_array_cookie_with_new_from_class.cpp
index 23d65100f96a8..da7e99681bbf5 100644
--- a/compiler-rt/test/asan/TestCases/Posix/new_array_cookie_with_new_from_class.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/new_array_cookie_with_new_from_class.cpp
@@ -1,8 +1,6 @@
// Test that we do not poison the array cookie if the operator new is defined
// inside the class.
// RUN: %clangxx_asan %s -o %t && %run %t
-//
-// XFAIL: target=arm{{.*}}
// UNSUPPORTED: darwin-remote
@@ -11,6 +9,13 @@
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
+
+#if defined(__arm__) || defined(__arm64__)
+static const size_t kArrayCookieSize = 2 * sizeof(void *);
+#else
+static const size_t kArrayCookieSize = sizeof(void *);
+#endif
+
struct Foo {
void *operator new(size_t s) { return Allocate(s); }
void *operator new[] (size_t s) { return Allocate(s); }
@@ -34,7 +39,7 @@ int main() {
fprintf(stderr, "foo : %p\n", foo);
fprintf(stderr, "alloc: %p\n", Foo::allocated);
assert(reinterpret_cast<uintptr_t>(foo) ==
- reinterpret_cast<uintptr_t>(Foo::allocated) + sizeof(void*));
+ reinterpret_cast<uintptr_t>(Foo::allocated) + kArrayCookieSize);
*reinterpret_cast<uintptr_t*>(Foo::allocated) = 42;
return 0;
}
More information about the llvm-commits
mailing list