brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · c8ed3fd Raw
37 lines · cpp
1// Check that without suppressions, we catch the issue.2// RUN: %clangxx_asan -O0 %s -o %t3// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s4 5// RUN: echo "interceptor_via_fun:crash_function" > %t.supp6// RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s7// RUN: %clangxx_asan -O3 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s8 9// FIXME: Upload suppressions to device.10// XFAIL: android11// UNSUPPORTED: ios12 13// FIXME: atos does not work for inlined functions, yet llvm-symbolizer14// does not always work with debug info on Darwin. Behavior is similar on MSVC x86 outside of /Od.15// UNSUPPORTED: darwin16// UNSUPPORTED: target={{.*windows-msvc.*}} && asan-32-bits17 18#include <stdio.h>19#include <stdlib.h>20#include <string.h>21 22void crash_function() {23  char *a = (char *)malloc(6);24  free(a);25  size_t len = strlen(a); // BOOM26  fprintf(stderr, "strlen ignored, len = %zu\n", len);27}28 29int main() {30  crash_function();31}32 33// CHECK-CRASH: AddressSanitizer: heap-use-after-free34// CHECK-CRASH-NOT: strlen ignored35// CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free36// CHECK-IGNORE: strlen ignored37