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