diff --git a/compiler-rt/lib/safestack/safestack.cc b/compiler-rt/lib/safestack/safestack.cc --- a/compiler-rt/lib/safestack/safestack.cc +++ b/compiler-rt/lib/safestack/safestack.cc @@ -83,7 +83,7 @@ const unsigned kDefaultUnsafeStackSize = 0x2800000; /// Runtime page size obtained through sysconf -unsigned pageSize; +unsigned pageSize = 4096; // Per-thread unsafe stack information. It's not frequently accessed, so there // it can be kept out of the tcb in normal thread-local variables. @@ -264,11 +264,9 @@ __attribute__((constructor(0))) #endif void __safestack_init() { - pageSize = sysconf(_SC_PAGESIZE); - // Determine the stack size for the main thread. size_t size = kDefaultUnsafeStackSize; - size_t guard = 4096; + size_t guard = pageSize; struct rlimit limit; if (getrlimit(RLIMIT_STACK, &limit) == 0 && limit.rlim_cur != RLIM_INFINITY) @@ -276,8 +274,8 @@ // Allocate unsafe stack for main thread void *addr = unsafe_stack_alloc(size, guard); - unsafe_stack_setup(addr, size, guard); + pageSize = sysconf(_SC_PAGESIZE); // Setup the cleanup handler pthread_key_create(&thread_cleanup_key, thread_cleanup_handler);