197ccf6b8SFangrui Song // Test that stack of main thread is included in the root set.
297ccf6b8SFangrui Song // RUN: %clangxx_lsan %s -o %t
3*d08e5d4cSClemens Wasser // RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0" not %run %t 2>&1 | FileCheck %s
4*d08e5d4cSClemens Wasser // RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=1" %run %t 2>&1
597ccf6b8SFangrui Song // RUN: %env_lsan_opts="" %run %t 2>&1
697ccf6b8SFangrui Song 
797ccf6b8SFangrui Song #include <stdio.h>
897ccf6b8SFangrui Song #include <stdlib.h>
997ccf6b8SFangrui Song #include "sanitizer_common/print_address.h"
1097ccf6b8SFangrui Song 
main()1197ccf6b8SFangrui Song int main() {
1297ccf6b8SFangrui Song   void *stack_var = malloc(1337);
1397ccf6b8SFangrui Song   print_address("Test alloc: ", 1, stack_var);
1497ccf6b8SFangrui Song   // Do not return from main to prevent the pointer from going out of scope.
1597ccf6b8SFangrui Song   exit(0);
1697ccf6b8SFangrui Song }
1797ccf6b8SFangrui Song // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
1897ccf6b8SFangrui Song // CHECK: LeakSanitizer: detected memory leaks
1997ccf6b8SFangrui Song // CHECK: [[ADDR]] (1337 bytes)
2097ccf6b8SFangrui Song // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
21