1 // RUN: %clang_hwasan -Wl,--build-id -g %s -o %t
2 // RUN: echo '[{"prefix": "'"$(realpath $(dirname %s))"'/", "link": "http://test.invalid/{file}:{line}"}]' > %t.linkify
3 // RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | hwasan_symbolize --html --symbols $(dirname %t) --index | FileCheck %s
4 // RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | hwasan_symbolize --html --linkify %t.linkify --symbols $(dirname %t) --index | FileCheck --check-prefixes=CHECK,LINKIFY %s
5 // RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | hwasan_symbolize --symbols $(dirname %t) --index | FileCheck %s
6 
7 // There are currently unrelated problems on x86_64, so skipping for now.
8 // REQUIRES: android
9 // REQUIRES: stable-runtime
10 
11 #include <sanitizer/hwasan_interface.h>
12 #include <stdlib.h>
13 
14 static volatile char sink;
15 
16 int main(int argc, char **argv) {
17   __hwasan_enable_allocator_tagging();
18   char *volatile x = (char *)malloc(10);
19   sink = x[100];
20   // LINKIFY: <a href="http://test.invalid/hwasan_symbolize.cpp:[[@LINE-1]]">
21   // CHECK: hwasan_symbolize.cpp:[[@LINE-2]]
22   // CHECK: Cause: heap-buffer-overflow
23   // CHECK: allocated here:
24   // LINKIFY: <a href="http://test.invalid/hwasan_symbolize.cpp:[[@LINE-6]]">
25   // CHECK: hwasan_symbolize.cpp:[[@LINE-7]]
26   return 0;
27 }
28