| 1 |
// RUN: %clangxx_hwasan -DERR=1 %s -o %t && not %run %t 2>&1 | FileCheck %s |
| 2 |
// RUN: %clangxx_hwasan -DERR=2 %s -o %t && not %run %t 2>&1 | FileCheck %s |
| 3 |
// REQUIRES: android |
| 4 |
|
| 5 |
#include <stdlib.h> |
| 6 |
#include <stdio.h> |
| 7 |
|
| 8 |
#include <sanitizer/hwasan_interface.h> |
| 9 |
|
| 10 |
__attribute__((no_sanitize("hwaddress"))) |
| 11 |
extern "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 |
|
| 15 |
int 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 start |
| 26 |
// CHECK: ERROR: HWAddressSanitizer: |
| 27 |
// CHECK: == abort message end |
| 28 |
} |