]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/large_allocator_unpoisons_on_free.cc
1 // Test that LargeAllocator unpoisons memory before releasing it to the OS.
2 // RUN: %clangxx_asan %s -o %t
3 // The memory is released only when the deallocated chunk leaves the quarantine,
4 // otherwise the mmap(p, ...) call overwrites the malloc header.
5 // RUN: ASAN_OPTIONS=quarantine_size=1 %run %t
14 void *my_memalign(size_t boundary
, size_t size
) {
15 return memalign(boundary
, size
);
18 void *my_memalign(size_t boundary
, size_t size
) {
20 posix_memalign(&p
, boundary
, size
);
26 const int kPageSize
= 4096;
27 void *p
= my_memalign(kPageSize
, 1024 * 1024);
30 char *q
= (char *)mmap(p
, kPageSize
, PROT_READ
| PROT_WRITE
, MAP_PRIVATE
| MAP_ANON
| MAP_FIXED
, 0, 0);
33 memset(q
, 42, kPageSize
);