1// Check that without suppressions, we catch the issue.
2// RUN: %clangxx_asan -O0 %s -o %t
3// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
4
5// RUN: echo "interceptor_name:strlen" > %t.supp
6// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
7
8// FIXME: Upload suppressions to device.
9// XFAIL: android
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14
15int main() {
16 char *a = (char *)malloc(size: 6);
17 free(ptr: a);
18 size_t len = strlen(s: a); // BOOM
19 fprintf(stderr, format: "strlen ignored, len = %zu\n", len);
20}
21
22// CHECK-CRASH: AddressSanitizer: heap-use-after-free
23// CHECK-CRASH-NOT: strlen ignored
24// CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free
25// CHECK-IGNORE: strlen ignored
26

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of compiler-rt/test/asan/TestCases/suppressions-interceptor.cpp