1 // REQUIRES: asan-64-bits
2 // RUN: %clangxx_asan -O3 %s -o %t
3 // RUN: %env_asan_opts=poison_array_cookie=1 not %run %t 2>&1 | FileCheck %s --check-prefix=COOKIE
4 // RUN: %env_asan_opts=poison_array_cookie=0 not %run %t 2>&1 | FileCheck %s --check-prefix=NO_COOKIE
13 fprintf(stderr, "DTOR %d\n", dtor_counter);
17 __attribute__((noinline)) void Delete(C *c) { delete[] c; }
18 __attribute__((no_sanitize_address)) void Write42ToCookie(C *c) {
19 long *p = reinterpret_cast<long*>(c);
23 int main(int argc, char **argv) {
24 C *buffer = new C[argc];
26 Write42ToCookie(buffer);
30 // COOKIE: AddressSanitizer: loaded array cookie from free-d memory
31 // COOKIE: AddressSanitizer: attempting double-free
34 // NO_COOKIE-NOT: DTOR 44
35 // NO_COOKIE-NOT: AddressSanitizer: loaded array cookie from free-d memory
36 // NO_COOKIE: AddressSanitizer: attempting double-free