1 | // RUN: rm -rf %t && mkdir -p %t |
2 | // RUN: %clang_hwasan -Wl,--build-id -g %s -o %t/hwasan_symbolize_test |
3 | // RUN: echo '[{"prefix": "'"%S"'/", "link": "http://test.invalid/{file}:{line}"}]' > %t/hwasan_symbolize_test.linkify |
4 | // RUN: %env_hwasan_opts=symbolize=0 not %run %t/hwasan_symbolize_test 2>&1 | hwasan_symbolize --html --symbols %t --index | FileCheck %s |
5 | // RUN: %env_hwasan_opts=symbolize=0 not %run %t/hwasan_symbolize_test 2>&1 | hwasan_symbolize --html --linkify %t/hwasan_symbolize_test.linkify --symbols %t --index | FileCheck --check-prefixes=CHECK,LINKIFY %s |
6 | // RUN: %env_hwasan_opts=symbolize=0 not %run %t/hwasan_symbolize_test 2>&1 | hwasan_symbolize --symbols %t --index | FileCheck %s |
7 | |
8 | #include <sanitizer/hwasan_interface.h> |
9 | #include <stdlib.h> |
10 | |
11 | static volatile char sink; |
12 | |
13 | int main(int argc, char **argv) { |
14 | __hwasan_enable_allocator_tagging(); |
15 | char *volatile x = (char *)malloc(size: 10); |
16 | sink = x[100]; |
17 | // LINKIFY: <a href="http://test.invalid/hwasan_symbolize.cpp:[[@LINE-1]]"> |
18 | // CHECK: hwasan_symbolize.cpp:[[@LINE-2]] |
19 | // CHECK: Cause: heap-buffer-overflow |
20 | // CHECK: allocated by thread {{.*}} here: |
21 | // LINKIFY: <a href="http://test.invalid/hwasan_symbolize.cpp:[[@LINE-6]]"> |
22 | // CHECK: hwasan_symbolize.cpp:[[@LINE-7]] |
23 | return 0; |
24 | } |
25 | |