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

source code of compiler-rt/test/hwasan/TestCases/hwasan_symbolize.cpp