]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/lsan/TestCases/do_leak_check_override.cc
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: LSAN_BASE="use_stacks=0:use_registers=0"
5 // RUN: %clangxx_lsan %s -o %t
6 // RUN: %env_lsan_opts=$LSAN_BASE not %run %t 2>&1 | FileCheck --check-prefix=CHECK-strict %s
7 // RUN: %env_lsan_opts=$LSAN_BASE not %run %t foo 2>&1 | FileCheck --check-prefix=CHECK-normal %s
11 #include <sanitizer/lsan_interface.h>
23 LeakyGlobal leaky_global
;
25 int main(int argc
, char *argv
[]) {
26 // Register leak check to run before global destructors.
28 atexit(&__lsan_do_leak_check
);
29 void *p
= malloc(666);
30 printf("Test alloc: %p\n", p
);
31 printf("Test alloc in leaky global: %p\n", leaky_global
.p
);
35 // CHECK-strict: SUMMARY: {{(Leak|Address)}}Sanitizer: 2003 byte(s) leaked in 2 allocation(s)
36 // CHECK-normal: SUMMARY: {{(Leak|Address)}}Sanitizer: 666 byte(s) leaked in 1 allocation(s)