[llvm-branch-commits] [compiler-rt] [clang-tools-extra] [llvm] [clang] [sanitizer_symbolizer] Add end to end test for symbolizer markup. (PR #77702)

Andres Villegas via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 11 12:24:15 PST 2024


=?utf-8?q?Andrés?= Villegas <andresvi at google.com>,
=?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.*}}
----------------
avillega wrote:

Added CHECK-NEXT and CHECK-DAG in some places. because of how the symvolizer markup context elements currently work, it is possible to get a line containing module information in the middle of two lines that might be expected to be NEXT to each other. I think it is something we might want to review.

https://github.com/llvm/llvm-project/pull/77702


More information about the llvm-branch-commits mailing list