From 6569120b813d8b39f7d3dc7da2c4dac0a0368dfb Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Thu, 7 Feb 2019 22:26:04 +0000 Subject: [PATCH] [safestack] Don't crash if stack size is not aligned as expected Summary: From runtime side looks it's OK to RoundUpTo to needed alignment as buffer is going to be RoundUpTo to page size anyway. Reviewers: eugenis, pcc Subscribers: #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D57866 llvm-svn: 353475 --- compiler-rt/lib/safestack/safestack.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/lib/safestack/safestack.cc b/compiler-rt/lib/safestack/safestack.cc index ff840a5c19db..3c26d9ae88b3 100644 --- a/compiler-rt/lib/safestack/safestack.cc +++ b/compiler-rt/lib/safestack/safestack.cc @@ -228,7 +228,7 @@ INTERCEPTOR(int, pthread_create, pthread_t *thread, } SFS_CHECK(size); - SFS_CHECK((size & (kStackAlign - 1)) == 0); + size = RoundUpTo(size, kStackAlign); SFS_CHECK((guard & (pageSize - 1)) == 0); void *addr = unsafe_stack_alloc(size, guard);