32 lines · cpp
1// RUN: %clangxx_asan %s -o %t2// RUN: %env_asan_opts=print_module_map=1 not %run %t 2>&1 | FileCheck %s3// RUN: %env_asan_opts=print_module_map=2 not %run %t 2>&1 | FileCheck %s4// RUN: %clangxx_asan %s -o %t -fsanitize-recover=address5// RUN: %env_asan_opts=print_module_map=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s6 7// We can't run system("otool") in the simulator.8// UNSUPPORTED: ios9 10#include <stdio.h>11#include <stdlib.h>12#include <string.h>13 14int main(int argc, char *argv[]) {15 char buf[2048];16 snprintf(buf, sizeof(buf), "otool -l %s 1>&2", argv[0]);17 system(buf);18 // CHECK: cmd LC_UUID19 // CHECK-NEXT: cmdsize 2420 // CHECK-NEXT: uuid [[UUID:[0-9A-F-]{36}]]21 22 char *x = (char*)malloc(10 * sizeof(char));23 free(x);24 char mybuf[10];25 memcpy(mybuf, x, 10);26 // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}27 // CHECK: Process module map:28 // CHECK: uuid.cpp.tmp {{.*}} <[[UUID]]>29 30 fprintf(stderr, "Done.\n");31}32