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