brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1014 B · 7487bd4 Raw
29 lines · cpp
1// Check that the `atos` symbolizer works.2 3// RUN: %clangxx_asan -O0 %s -o %t4// RUN: which atos | tr -d '\n' > %t.symbolizer_path5// RUN: %env_asan_opts=verbosity=2 ASAN_SYMBOLIZER_PATH=%{readfile:%t.symbolizer_path} not %run %t 2>&1 | FileCheck %s6 7// Path returned by `which atos` is invalid on iOS.8// UNSUPPORTED: ios, i386-darwin9 10#include <stdlib.h>11#include <string.h>12int main(int argc, char **argv) {13  char *x = (char*)malloc(10 * sizeof(char));14  memset(x, 0, 10);15  int res = x[argc];16  free(x);17  free(x + argc - 1);  // BOOM18  // CHECK: Using atos at user-specified path:19  // CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T020  // CHECK: #0 0x{{.*}} in {{.*}}free21  // CHECK: #1 0x{{.*}} in main {{.*}}atos-symbolizer.cpp:[[@LINE-4]]22  // CHECK: freed by thread T0 here:23  // CHECK: #0 0x{{.*}} in {{.*}}free24  // CHECK: #1 0x{{.*}} in main {{.*}}atos-symbolizer.cpp:[[@LINE-8]]25  // CHECK: allocated by thread T0 here:26  // CHECK: atos-symbolizer.cpp:[[@LINE-13]]27  return res;28}29