Skip to content

Commit 89e8106

Browse files
authored
Merge pull request #8824 from apple/fake_stack_fix_stack_addresses
🍒 [test][asan] Use posix_memalign for stacks
2 parents de66661 + 1655795 commit 89e8106

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

@@ -63,8 +64,11 @@ void *Thread(void *arg) {
6364

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

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

0 commit comments

Comments
 (0)