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: %env_asan_opts=quarantine_size_mb=0 %run %t
15 void *my_memalign(size_t boundary
, size_t size
) {
16 return memalign(boundary
, size
);
19 void *my_memalign(size_t boundary
, size_t size
) {
21 posix_memalign(&p
, boundary
, size
);
27 const long kPageSize
= sysconf(_SC_PAGESIZE
);
28 void *p
= my_memalign(kPageSize
, 1024 * 1024);
31 char *q
= (char *)mmap(p
, kPageSize
, PROT_READ
| PROT_WRITE
,
32 MAP_PRIVATE
| MAP_ANON
| MAP_FIXED
, -1, 0);
35 memset(q
, 42, kPageSize
);