1 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 2 // XFAIL: android 3 // UNSUPPORTED: ios 4 // 5 // The for loop in the backticks below requires bash. 6 // REQUIRES: shell 7 // 8 // RUN: %clangxx_asan %s -o %t 9 10 // Regular run. 11 // RUN: not %run %t 2> %t.out 12 // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out 13 14 // Good log_path. 15 // RUN: rm -f %t.log.* 16 // RUN: %env_asan_opts=log_path=%t.log not %run %t 2> %t.out 17 // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.* 18 19 // Invalid log_path. 20 // RUN: %env_asan_opts=log_path=/dev/null/INVALID not %run %t 2> %t.out 21 // RUN: FileCheck %s --check-prefix=CHECK-INVALID < %t.out 22 23 // Too long log_path. 24 // RUN: %env_asan_opts=log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \ 25 // RUN: not %run %t 2> %t.out 26 // RUN: FileCheck %s --check-prefix=CHECK-LONG < %t.out 27 28 // Run w/o errors should not produce any log. 29 // RUN: rm -f %t.log.* 30 // RUN: %env_asan_opts=log_path=%t.log %run %t ARG ARG ARG 31 // RUN: not cat %t.log.* 32 33 // FIXME: log_path is not supported on Windows yet. 34 // XFAIL: windows-msvc 35 36 #include <stdlib.h> 37 #include <string.h> 38 int main(int argc, char **argv) { 39 if (argc > 2) return 0; 40 char *x = (char*)malloc(10); 41 memset(x, 0, 10); 42 int res = x[argc * 10]; // BOOOM 43 free(x); 44 return res; 45 } 46 // CHECK-ERROR: ERROR: AddressSanitizer 47 // CHECK-INVALID: ERROR: Can't open file: /dev/null/INVALID 48 // CHECK-LONG: ERROR: Path is too long: 01234 49