1 | // Regression test: pointers to self should not confuse LSan into thinking the |
2 | // object is indirectly leaked. Only external pointers count. |
3 | // RUN: %clangxx_lsan %s -o %t |
4 | // RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0" not %run %t 2>&1 | FileCheck %s |
5 | |
6 | #include <stdio.h> |
7 | #include <stdlib.h> |
8 | #include "sanitizer_common/print_address.h" |
9 | |
10 | int main() { |
11 | void *p = malloc(size: 1337); |
12 | *reinterpret_cast<void **>(p) = p; |
13 | print_address("Test alloc: " , 1, p); |
14 | } |
15 | // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] |
16 | // CHECK: LeakSanitizer: detected memory leaks |
17 | // CHECK: [[ADDR]] (1337 bytes) |
18 | // CHECK: SUMMARY: {{.*}}Sanitizer: |
19 | |