[llvm-branch-commits] [clang-tools-extra] [llvm] [compiler-rt] [clang] [sanitizer_symbolizer] Add end to end test for symbolizer markup. (PR #77702)
Paul Kirth via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 11 10:30:16 PST 2024
=?utf-8?q?Andrés?= Villegas <andresvi at google.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/77702 at github.com>
================
@@ -0,0 +1,33 @@
+// COM: End to end test for the sanitizer symbolizer markup. Since it uses debug info
+// COM: to do offline symbolization we only check that the current module is correctly symbolized
+// REQUIRES: linux
+// RUN: %clangxx_asan %s -Wl,--build-id=0x12345678 -o %t.main
+// RUN: mkdir -p %t/.build-id/12
+// RUN: cp %t.main %t/.build-id/12/345678.debug
+// RUN: %env_asan_opts=enable_symbolizer_markup=1 not %run %t.main 2>%t/sanitizer.out
+// RUN: llvm-symbolizer --filter-markup --debug-file-directory=%t < %t/sanitizer.out | FileCheck %s
+
+#include <stdlib.h>
+
+[[gnu::noinline]] char *alloc() {
+ char *x = (char *)malloc(10 * sizeof(char));
+ return x;
+}
+int main() {
+ char *x = alloc();
+ free(x);
+ return x[5];
+}
+// CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
+// CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
+// CHECK: {{READ of size 1 at 0x.* thread T0}}
+// CHECK: {{ #0 0x.* main .*use-after-free-symbolizer-markup.cpp:}}[[@LINE-5]]
+// CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
+// CHECK: {{freed by thread T0 here:}}
+// CHECK: {{ #1 0x.* main .*use-after-free-symbolizer-markup.cpp:}}[[@LINE-9]]
+// CHECK: {{previously allocated by thread T0 here:}}
+// CHECK: {{ #1 0x.* alloc\(\) .*use-after-free-symbolizer-markup.cpp:}}[[@LINE-16]]
----------------
ilovepi wrote:
```suggestion
// CHECK: {{ #1 0x.* alloc\(\) .*use-after-free-symbolizer-markup.cpp:}}[[#@LINE-16]]
```
Note: `[[@LINE]]` is deprecated. Use `[[#@LINE]]`.
https://github.com/llvm/llvm-project/pull/77702
More information about the llvm-branch-commits
mailing list