29 lines · cpp
1// RUN: %clangxx_hwasan -DERR=1 %s -o %t && not %run %t 2>&1 | FileCheck %s2// RUN: %clangxx_hwasan -DERR=2 %s -o %t && not %run %t 2>&1 | FileCheck %s3// REQUIRES: android4 5#include <stdlib.h>6#include <stdio.h>7 8#include <sanitizer/hwasan_interface.h>9 10__attribute__((no_sanitize("hwaddress")))11extern "C" void android_set_abort_message(const char *msg) {12 fprintf(stderr, "== abort message start\n%s\n== abort message end\n", msg);13}14 15int main() {16 __hwasan_enable_allocator_tagging();17 char *volatile p = (char *)malloc(16);18 if (ERR==1) {19 p[16] = 1;20 } else {21 free(p);22 free(p);23 }24 // CHECK: ERROR: HWAddressSanitizer:25 // CHECK: == abort message start26 // CHECK: ERROR: HWAddressSanitizer:27 // CHECK: == abort message end28}29