1 // Test for __lsan_do_leak_check(). We test it by making the leak check run
2 // before global destructors, which also tests compatibility with HeapChecker's
3 // "normal" mode (LSan runs in "strict" mode by default).
4 // RUN: %clangxx_lsan %s -o %t
5 // RUN: %env_lsan_opts=use_stacks=0:use_registers=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-strict %s
6 // RUN: %env_lsan_opts=use_stacks=0:use_registers=0 not %run %t foo 2>&1 | FileCheck --check-prefix=CHECK-normal %s
8 // Investigate why LeakyGlobal leak does show
9 // UNSUPPORTED: arm-linux || armhf-linux
13 #include <sanitizer/lsan_interface.h>
25 LeakyGlobal leaky_global
;
27 int main(int argc
, char *argv
[]) {
28 // Register leak check to run before global destructors.
30 atexit(&__lsan_do_leak_check
);
31 void *p
= malloc(666);
32 printf("Test alloc: %p\n", p
);
33 printf("Test alloc in leaky global: %p\n", leaky_global
.p
);
37 // CHECK-strict: SUMMARY: {{.*}}Sanitizer: 2003 byte(s) leaked in 2 allocation(s)
38 // CHECK-normal: SUMMARY: {{.*}}Sanitizer: 666 byte(s) leaked in 1 allocation(s)