Skip to content

Commit 8b7b434

Browse files
committed
[test][asan] Use posix_memalign for stacks
Looks Android and Darwin fail because of alignment.
1 parent 52d1cda commit 8b7b434

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler-rt/test/asan/TestCases/Posix/fake_stack_gc.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <signal.h>
1212
#include <stdio.h>
1313
#include <stdlib.h>
14+
#include <unistd.h>
1415

1516
const size_t kStackSize = 0x100000;
1617

@@ -62,8 +63,11 @@ void *Thread(void *arg) {
6263

6364
int main(void) {
6465
// Allocate main and alt stack for future thread.
65-
void *main_stack = malloc(kStackSize);
66-
void *alt_stack = malloc(kStackSize);
66+
void *main_stack;
67+
void *alt_stack;
68+
size_t const kPageSize = sysconf(_SC_PAGESIZE);
69+
assert(posix_memalign(&main_stack, kPageSize, kStackSize) == 0);
70+
assert(posix_memalign(&alt_stack, kPageSize, kStackSize) == 0);
6771

6872
// Pick the lower stack as the main stack, as we want to trigger GC in
6973
// FakeStack from alt stack in a such way that main stack is allocated below.

0 commit comments

Comments
 (0)