1 // RUN: %clangxx_lsan %s -o %t
2 // The globs below do not work in the lit shell.
3 
4 // Regular run.
5 // RUN: %env_lsan_opts="use_stacks=0" not %run %t > %t.out 2>&1
6 // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out
7 
8 // Good log_path.
9 // RUN: rm -f %t.log.*
10 // RUN: %env_lsan_opts="use_stacks=0:log_path='"%t.log"'" not %run %t > %t.out 2>&1
11 // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.*
12 
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include "sanitizer_common/print_address.h"
16 
17 int main() {
18   void *stack_var = malloc(1337);
19   print_address("Test alloc: ", 1, stack_var);
20   // Do not return from main to prevent the pointer from going out of scope.
21   exit(0);
22 }
23 
24 // CHECK-ERROR: LeakSanitizer: detected memory leaks
25 // CHECK-ERROR: Direct leak of 1337 byte(s) in 1 object(s) allocated from
26 // CHECK-ERROR: SUMMARY: {{(Leak|Address)}}Sanitizer:
27