diff --git a/compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp b/compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp --- a/compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp +++ b/compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp @@ -1,18 +1,22 @@ // Test that SIGSEGV during leak checking does not crash the process. // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s // REQUIRES: leak-detection -#include +#include #include +#include #include -#include +#include char data[10 * 1024 * 1024]; int main() { void *p = malloc(10 * 1024 * 1024); + const unsigned long kPageBitsMask = getpagesize() - 1; // surprise-surprise! - mprotect((void*)(((unsigned long)p + 4095) & ~4095), 16 * 1024, PROT_NONE); - mprotect((void*)(((unsigned long)data + 4095) & ~4095), 16 * 1024, PROT_NONE); + mprotect((void *)(((unsigned long)p + kPageBitsMask) & ~kPageBitsMask), + 16 * 1024, PROT_NONE); + mprotect((void *)(((unsigned long)data + kPageBitsMask) & ~kPageBitsMask), + 16 * 1024, PROT_NONE); __lsan_do_leak_check(); fprintf(stderr, "DONE\n"); }