[llvm-branch-commits] [clang-tools-extra] [clang] [llvm] [compiler-rt] [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.*}}
----------------
ilovepi wrote:

If you expect these to be in order, `CHECK-NEXT:` or `CHECK-DAG:` are probably better.

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


More information about the llvm-branch-commits mailing list