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 // REQUIRES: stable-runtime
8 
9 #include <sanitizer/hwasan_interface.h>
10 #include <stdlib.h>
11 
12 static volatile char sink;
13 
main(int argc,char ** argv)14 int main(int argc, char **argv) {
15   __hwasan_enable_allocator_tagging();
16   char *volatile x = (char *)malloc(10);
17   sink = x[100];
18   // LINKIFY: <a href="http://test.invalid/hwasan_symbolize.cpp:[[@LINE-1]]">
19   // CHECK: hwasan_symbolize.cpp:[[@LINE-2]]
20   // CHECK: Cause: heap-buffer-overflow
21   // CHECK: allocated here:
22   // LINKIFY: <a href="http://test.invalid/hwasan_symbolize.cpp:[[@LINE-6]]">
23   // CHECK: hwasan_symbolize.cpp:[[@LINE-7]]
24   return 0;
25 }
26