1 // RUN: %clangxx_lsan %s -o %t 2 // RUN: %env_lsan_opts=use_registers=0:use_stacks=0 not %run %t 2>&1 | FileCheck %s 3 4 #include <stdio.h> 5 #include <stdlib.h> 6 7 #include "sanitizer/lsan_interface.h" 8 9 extern "C" __lsan_default_suppressions()10const char *__lsan_default_suppressions() { 11 return "leak:*LSanTestLeakingFunc*"; 12 } 13 LSanTestLeakingFunc()14void LSanTestLeakingFunc() { 15 void *p = malloc(666); 16 fprintf(stderr, "Test alloc: %p.\n", p); 17 } 18 main()19int main() { 20 LSanTestLeakingFunc(); 21 void *q = malloc(1337); 22 fprintf(stderr, "Test alloc: %p.\n", q); 23 return 0; 24 } 25 // CHECK: Suppressions used: 26 // CHECK: 1 666 *LSanTestLeakingFunc* 27 // CHECK: SUMMARY: {{.*}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s) 28