[compiler-rt] 8b7b434 - [test][asan] Use posix_memalign for stacks
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 23:47:32 PDT 2023
Author: Vitaly Buka
Date: 2023-08-15T23:47:15-07:00
New Revision: 8b7b434087cc4dc85e64632ae2780300c3c5d332
URL: https://github.com/llvm/llvm-project/commit/8b7b434087cc4dc85e64632ae2780300c3c5d332
DIFF: https://github.com/llvm/llvm-project/commit/8b7b434087cc4dc85e64632ae2780300c3c5d332.diff
LOG: [test][asan] Use posix_memalign for stacks
Looks Android and Darwin fail because of alignment.
Added:
Modified:
compiler-rt/test/asan/TestCases/Posix/fake_stack_gc.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/asan/TestCases/Posix/fake_stack_gc.cpp b/compiler-rt/test/asan/TestCases/Posix/fake_stack_gc.cpp
index 82ad64eef36c1a..696d75ae7e1a84 100644
--- a/compiler-rt/test/asan/TestCases/Posix/fake_stack_gc.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/fake_stack_gc.cpp
@@ -11,6 +11,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
const size_t kStackSize = 0x100000;
@@ -62,8 +63,11 @@ void *Thread(void *arg) {
int main(void) {
// Allocate main and alt stack for future thread.
- void *main_stack = malloc(kStackSize);
- void *alt_stack = malloc(kStackSize);
+ void *main_stack;
+ void *alt_stack;
+ size_t const kPageSize = sysconf(_SC_PAGESIZE);
+ assert(posix_memalign(&main_stack, kPageSize, kStackSize) == 0);
+ assert(posix_memalign(&alt_stack, kPageSize, kStackSize) == 0);
// Pick the lower stack as the main stack, as we want to trigger GC in
// FakeStack from alt stack in a such way that main stack is allocated below.
More information about the llvm-commits
mailing list