1 // Test for __lsan_ignore_object().
2 // RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_tls=0"
3 // RUN: %clang_lsan %s -o %t
4 // RUN: %env_lsan_opts=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
5 
6 // Investigate why it does not fail with use_stack=0
7 // UNSUPPORTED: arm-linux || armhf-linux
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 #include "sanitizer/lsan_interface.h"
13 
main()14 int main() {
15   // Explicitly ignored object.
16   void **p = malloc(sizeof(void *));
17   // Transitively ignored object.
18   *p = malloc(666);
19   // Non-ignored object.
20   volatile void *q = malloc(1337);
21   fprintf(stderr, "Test alloc: %p.\n", p);
22   __lsan_ignore_object(p);
23   return 0;
24 }
25 // CHECK: Test alloc: [[ADDR:.*]].
26 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
27