Home | History | Annotate | Download | only in TestCases
      1 // Test that stack of main thread is included in the root set.
      2 // RUN: LSAN_BASE="report_objects=1:use_registers=0"
      3 // RUN: %clangxx_lsan %s -o %t
      4 // RUN: LSAN_OPTIONS=$LSAN_BASE:"use_stacks=0" not %run %t 2>&1 | FileCheck %s
      5 // RUN: LSAN_OPTIONS=$LSAN_BASE:"use_stacks=1" %run %t 2>&1
      6 // RUN: LSAN_OPTIONS="" %run %t 2>&1
      7 
      8 #include <stdio.h>
      9 #include <stdlib.h>
     10 
     11 int main() {
     12   void *stack_var = malloc(1337);
     13   fprintf(stderr, "Test alloc: %p.\n", stack_var);
     14   // Do not return from main to prevent the pointer from going out of scope.
     15   exit(0);
     16 }
     17 // CHECK: Test alloc: [[ADDR:.*]].
     18 // CHECK: LeakSanitizer: detected memory leaks
     19 // CHECK: [[ADDR]] (1337 bytes)
     20 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
     21