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.* %t.log 10 // RUN: %adb_shell 'rm -f %t.log.*' 11 // RUN: %env_lsan_opts="use_stacks=0:log_path='"%device_rundir/%t.log"'" not %run %t > %t.out 2>&1 12 // adb-pull doesn't support wild cards so we need to rename the log file. 13 // RUN: cat %device_rundir/%t.log.* >> %t.log 14 // RUN: %adb_shell 'cat %device_rundir/%t.log.*' >> %t.log 15 // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.* 16 17 #include <stdio.h> 18 #include <stdlib.h> 19 #include "sanitizer_common/print_address.h" 20 21 int main() { 22 void *stack_var = malloc(1337); 23 print_address("Test alloc: ", 1, stack_var); 24 // Do not return from main to prevent the pointer from going out of scope. 25 exit(0); 26 } 27 28 // CHECK-ERROR: LeakSanitizer: detected memory leaks 29 // CHECK-ERROR: Direct leak of 1337 byte(s) in 1 object(s) allocated from 30 // CHECK-ERROR: SUMMARY: {{(Leak|Address)}}Sanitizer: 31