summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2013-11-22 11:19:28 +0000
committerAlexander Potapenko <glider@google.com>2013-11-22 11:19:28 +0000
commit32474d622605ec7ed3fcf6d53b8317949ed98964 (patch)
treeb193ad79ee9f6d7fccfd83736057a7b10e5956ff
parent8f944b6672b2e0cb8336c829ab6e932f9dd3651b (diff)
downloadbcm5719-llvm-32474d622605ec7ed3fcf6d53b8317949ed98964.tar.gz
bcm5719-llvm-32474d622605ec7ed3fcf6d53b8317949ed98964.zip
[ASan] Fix large_allocator_unpoisons_on_free.cc to pass correct parameters to mmap() on OSX.
llvm-svn: 195443
-rw-r--r--compiler-rt/lib/asan/lit_tests/TestCases/large_allocator_unpoisons_on_free.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/TestCases/large_allocator_unpoisons_on_free.cc b/compiler-rt/lib/asan/lit_tests/TestCases/large_allocator_unpoisons_on_free.cc
index 20caab7ad44..d1499d20648 100644
--- a/compiler-rt/lib/asan/lit_tests/TestCases/large_allocator_unpoisons_on_free.cc
+++ b/compiler-rt/lib/asan/lit_tests/TestCases/large_allocator_unpoisons_on_free.cc
@@ -1,5 +1,7 @@
// Test that LargeAllocator unpoisons memory before releasing it to the OS.
// RUN: %clangxx_asan %s -o %t
+// The memory is released only when the deallocated chunk leaves the quarantine,
+// otherwise the mmap(p, ...) call overwrites the malloc header.
// RUN: ASAN_OPTIONS=quarantine_size=1 %t
#include <assert.h>
@@ -8,16 +10,16 @@
#include <sys/mman.h>
int main() {
- void *p = malloc(1024 * 1024);
+ const int kPageSize = 4096;
+ void *p = NULL;
+ posix_memalign(&p, kPageSize, 1024 * 1024);
free(p);
- char *q = (char *)mmap(p, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0);
- assert(q);
- assert(q <= p);
- assert(q + 4096 > p);
+ char *q = (char *)mmap(p, kPageSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, 0, 0);
+ assert(q == p);
- memset(q, 42, 4096);
+ memset(q, 42, kPageSize);
- munmap(q, 4096);
+ munmap(q, kPageSize);
return 0;
}
OpenPOWER on IntegriCloud