[compiler-rt] [llvm] [RISCV][sanitizer] Fix sanitizer support for different virtual memory layout (PR #66743)

Hau Hsu via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 00:10:12 PDT 2024


https://github.com/hau-hsu updated https://github.com/llvm/llvm-project/pull/66743

>From 3e53c64b88ca051ca0f344ce920771fe85f4a42e Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng at gmail.com>
Date: Tue, 19 Sep 2023 14:45:32 +0800
Subject: [PATCH 1/3] [RISCV][sanitizer] Enable AP64 for RISCV64

D92403 has use AP32 by default for RISCV64 and then D126825 has move
this logic into sanitizer_common/sanitizer_platform.h which will effect
both asan and lsan, however asan are using AP64 and lsan using AP32
before D126825, and AP64 should work well for all 64-bit platform (ASan use that
before, so that's kind of evidence), not sure why we choose AP32 for lsan
before.

We have 2 option here: 1) only limited lsan use AP32 for RISCV64, 2) or also
relax that for lsan to using AP64.
---
 compiler-rt/lib/sanitizer_common/sanitizer_platform.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index 5965281555059..140dccdbe63c3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -295,8 +295,8 @@
 // For such platforms build this code with -DSANITIZER_CAN_USE_ALLOCATOR64=0 or
 // change the definition of SANITIZER_CAN_USE_ALLOCATOR64 here.
 #ifndef SANITIZER_CAN_USE_ALLOCATOR64
-#  if (SANITIZER_RISCV64 && !SANITIZER_FUCHSIA) || SANITIZER_IOS || \
-      SANITIZER_DRIVERKIT
+#  if (SANITIZER_RISCV64 && !SANITIZER_FUCHSIA && !SANITIZER_LINUX) || \
+      SANITIZER_IOS || SANITIZER_DRIVERKIT
 #    define SANITIZER_CAN_USE_ALLOCATOR64 0
 #  elif defined(__mips64) || defined(__hexagon__)
 #    define SANITIZER_CAN_USE_ALLOCATOR64 0

>From b011f128e87608d2f401578e5721811eb85d8ac2 Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng at gmail.com>
Date: Tue, 19 Sep 2023 14:40:51 +0800
Subject: [PATCH 2/3] [RISCV][Asan] Use dynamic shadow offset to make it work
 on different width of virtual-memory system.

The original asan port was support Sv39 only, however Sv48 support has
landed to linux kernel[1] for a while, so we are trying to make it support
both Sv39 and Sv48, the key point is we need to use a dynamic offset for the
shadow region, this bring extra runtime overhead, but compare to other
overhead in ASan, this should be acceptable.

[1] https://www.phoronix.com/news/Linux-5.17-RISC-V-sv48
---
 compiler-rt/lib/asan/asan_mapping.h                      | 7 +++++--
 compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp     | 6 +++---
 llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/compiler-rt/lib/asan/asan_mapping.h b/compiler-rt/lib/asan/asan_mapping.h
index c5f95c07a2105..91fe60db6329a 100644
--- a/compiler-rt/lib/asan/asan_mapping.h
+++ b/compiler-rt/lib/asan/asan_mapping.h
@@ -72,7 +72,10 @@
 // || `[0x2000000000, 0x23ffffffff]` || LowShadow  ||
 // || `[0x0000000000, 0x1fffffffff]` || LowMem     ||
 //
-// Default Linux/RISCV64 Sv39 mapping:
+// Default Linux/RISCV64 Sv39 mapping with SHADOW_OFFSET == 0xd55550000;
+// (the exact location of SHADOW_OFFSET may vary depending the dynamic probing
+//  by FindDynamicShadowStart).
+//
 // || `[0x1555550000, 0x3fffffffff]` || HighMem    ||
 // || `[0x0fffffa000, 0x1555555fff]` || HighShadow ||
 // || `[0x0effffa000, 0x0fffff9fff]` || ShadowGap  ||
@@ -186,7 +189,7 @@
 #  elif SANITIZER_FREEBSD && defined(__aarch64__)
 #    define ASAN_SHADOW_OFFSET_CONST 0x0000800000000000
 #  elif SANITIZER_RISCV64
-#    define ASAN_SHADOW_OFFSET_CONST 0x0000000d55550000
+#    define ASAN_SHADOW_OFFSET_DYNAMIC
 #  elif defined(__aarch64__)
 #    define ASAN_SHADOW_OFFSET_CONST 0x0000001000000000
 #  elif defined(__powerpc64__)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 5d2dd3a7a658f..36284aa3e53c9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1096,7 +1096,8 @@ uptr GetMaxVirtualAddress() {
 #  if SANITIZER_NETBSD && defined(__x86_64__)
   return 0x7f7ffffff000ULL;  // (0x00007f8000000000 - PAGE_SIZE)
 #  elif SANITIZER_WORDSIZE == 64
-#    if defined(__powerpc64__) || defined(__aarch64__) || defined(__loongarch__)
+#    if defined(__powerpc64__) || defined(__aarch64__) || \
+        defined(__loongarch__) || SANITIZER_RISCV64
   // On PowerPC64 we have two different address space layouts: 44- and 46-bit.
   // We somehow need to figure out which one we are using now and choose
   // one of 0x00000fffffffffffUL and 0x00003fffffffffffUL.
@@ -1105,9 +1106,8 @@ uptr GetMaxVirtualAddress() {
   // This should (does) work for both PowerPC64 Endian modes.
   // Similarly, aarch64 has multiple address space layouts: 39, 42 and 47-bit.
   // loongarch64 also has multiple address space layouts: default is 47-bit.
+  // RISC-V 64 also has multiple address space layouts: 39, 48 and 57-bit.
   return (1ULL << (MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1)) - 1;
-#    elif SANITIZER_RISCV64
-  return (1ULL << 38) - 1;
 #    elif SANITIZER_MIPS64
   return (1ULL << 40) - 1;  // 0x000000ffffffffffUL;
 #    elif defined(__s390x__)
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 9cc978dc6c16e..c6be7a9c317cb 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -108,7 +108,7 @@ static const uint64_t kMIPS32_ShadowOffset32 = 0x0aaa0000;
 static const uint64_t kMIPS64_ShadowOffset64 = 1ULL << 37;
 static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36;
 static const uint64_t kLoongArch64_ShadowOffset64 = 1ULL << 46;
-static const uint64_t kRISCV64_ShadowOffset64 = 0xd55550000;
+static const uint64_t kRISCV64_ShadowOffset64 = kDynamicShadowSentinel;
 static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30;
 static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46;
 static const uint64_t kFreeBSDAArch64_ShadowOffset64 = 1ULL << 47;

>From 2dd3155bc6a2a95309fc4c61166f093b9ee0de77 Mon Sep 17 00:00:00 2001
From: Hau Hsu <hau.hsu at sifive.com>
Date: Thu, 23 May 2024 14:50:50 +0800
Subject: [PATCH 3/3] [asan] Make frame number checks more flexable

Use more flexable regex ([0-9]+) for frame number checks.
Since the frame numbers might change if some functions are not inlined.

Similar to
* https://github.com/llvm/llvm-project/commit/0360f3218a13666123849f6699216bdbebe64833
* https://github.com/llvm/llvm-project/commit/404bc5ca2ae5fffa45d5240dcf52b7f134988867
---
 .../test/asan/TestCases/Linux/stack-trace-dlclose.cpp  |  6 +++---
 .../test/asan/TestCases/Posix/strndup_oob_test.cpp     |  4 ++--
 compiler-rt/test/asan/TestCases/calloc-overflow.cpp    |  4 ++--
 compiler-rt/test/asan/TestCases/debug_stacks.cpp       |  8 ++++----
 compiler-rt/test/asan/TestCases/double-free.cpp        |  6 +++---
 .../test/asan/TestCases/malloc-size-too-big.cpp        |  4 ++--
 compiler-rt/test/asan/TestCases/strcpy-overlap.cpp     |  6 +++---
 compiler-rt/test/asan/TestCases/strdup_oob_test.cpp    |  2 +-
 compiler-rt/test/asan/TestCases/strncpy-overflow.cpp   |  8 ++++----
 .../test/asan/TestCases/use-after-free-right.cpp       | 10 +++++-----
 compiler-rt/test/asan/TestCases/use-after-free.cpp     | 10 +++++-----
 11 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cpp b/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cpp
index 899e0dfc6bda5..0456c1ac3ac96 100644
--- a/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cpp
+++ b/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cpp
@@ -41,6 +41,6 @@ int main(int argc, char **argv) {
 }
 #endif
 
-// CHECK: {{    #0 0x.* in (__interceptor_)?malloc}}
-// CHECK: {{    #1 0x.* \(<unknown module>\)}}
-// CHECK: {{    #2 0x.* in main}}
+// CHECK: {{    #[0-9]+ 0x.* in (__interceptor_)?malloc}}
+// CHECK: {{    #[0-9]+ 0x.* \(<unknown module>\)}}
+// CHECK: {{    #[0-9]+ 0x.* in main}}
diff --git a/compiler-rt/test/asan/TestCases/Posix/strndup_oob_test.cpp b/compiler-rt/test/asan/TestCases/Posix/strndup_oob_test.cpp
index 43e554723bd95..17ba1dfe9c39a 100644
--- a/compiler-rt/test/asan/TestCases/Posix/strndup_oob_test.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/strndup_oob_test.cpp
@@ -17,9 +17,9 @@ int main(int argc, char **argv) {
   char *copy = strndup(kString, 2);
   int x = copy[2 + argc];  // BOOM
   // CHECK: AddressSanitizer: heap-buffer-overflow
-  // CHECK: #0 {{.*}}main {{.*}}strndup_oob_test.cpp:[[@LINE-2]]
+  // CHECK: #{{[0-9+}} {{.*}}main {{.*}}strndup_oob_test.cpp:[[@LINE-2]]
   // CHECK-LABEL: allocated by thread T{{.*}} here:
-  // CHECK: #{{[01]}} {{.*}}strndup
+  // CHECK: #{{[0-9]}} {{.*}}strndup
   // CHECK: #{{.*}}main {{.*}}strndup_oob_test.cpp:[[@LINE-6]]
   // CHECK-LABEL: SUMMARY
   // CHECK: strndup_oob_test.cpp:[[@LINE-7]]
diff --git a/compiler-rt/test/asan/TestCases/calloc-overflow.cpp b/compiler-rt/test/asan/TestCases/calloc-overflow.cpp
index b930b65cd8c3b..5af54e2d7605a 100644
--- a/compiler-rt/test/asan/TestCases/calloc-overflow.cpp
+++ b/compiler-rt/test/asan/TestCases/calloc-overflow.cpp
@@ -10,8 +10,8 @@
 int main() {
   void *p = calloc(-1, 1000);
   // CHECK: {{ERROR: AddressSanitizer: calloc parameters overflow: count \* size \(.* \* 1000\) cannot be represented in type size_t}}
-  // CHECK: {{#0 0x.* in .*calloc}}
-  // CHECK: {{#[1-3] 0x.* in main .*calloc-overflow.cpp:}}[[@LINE-3]]
+  // CHECK: {{#[0-9]+ 0x.* in .*calloc}}
+  // CHECK: {{#[0-9]+ 0x.* in main .*calloc-overflow.cpp:}}[[@LINE-3]]
   // CHECK: SUMMARY: AddressSanitizer: calloc-overflow
 
   printf("calloc returned: %zu\n", (size_t)p);
diff --git a/compiler-rt/test/asan/TestCases/debug_stacks.cpp b/compiler-rt/test/asan/TestCases/debug_stacks.cpp
index 7c320bfcb2d98..d642e1770fadf 100644
--- a/compiler-rt/test/asan/TestCases/debug_stacks.cpp
+++ b/compiler-rt/test/asan/TestCases/debug_stacks.cpp
@@ -64,11 +64,11 @@ int main() {
   // CHECK: ERROR: AddressSanitizer: heap-use-after-free
   // CHECK: WRITE of size 1 at 0x{{.*}}
   // CHECK: freed by thread T0 here:
-  // CHECK: #0 [[FREE_FRAME_0]]
-  // CHECK: #1 [[FREE_FRAME_1]]
+  // CHECK: #{{[0-9]+}} [[FREE_FRAME_0]]
+  // CHECK: #{{[0-9]+}} [[FREE_FRAME_1]]
   // CHECK: previously allocated by thread T0 here:
-  // CHECK: #0 [[ALLOC_FRAME_0]]
-  // CHECK: #1 [[ALLOC_FRAME_1]]
+  // CHECK: #{{[0-9+]}} [[ALLOC_FRAME_0]]
+  // CHECK: #{{[0-9+]}} [[ALLOC_FRAME_1]]
 
   return 0;
 }
diff --git a/compiler-rt/test/asan/TestCases/double-free.cpp b/compiler-rt/test/asan/TestCases/double-free.cpp
index 7b61df0715afa..93c860613735e 100644
--- a/compiler-rt/test/asan/TestCases/double-free.cpp
+++ b/compiler-rt/test/asan/TestCases/double-free.cpp
@@ -18,11 +18,11 @@ int main(int argc, char **argv) {
   free(x);
   free(x + argc - 1);  // BOOM
   // CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T0
-  // CHECK: #0 0x{{.*}} in {{.*}}free
-  // CHECK: #{{[1-3]}} 0x{{.*}} in main {{.*}}double-free.cpp:[[@LINE-3]]
+  // CHECK: #{{[0-9]+}} 0x{{.*}} in {{.*}}free
+  // CHECK: #{{[0-9]+}} 0x{{.*}} in main {{.*}}double-free.cpp:[[@LINE-3]]
   // CHECK: freed by thread T0 here:
   // MALLOC-CTX: #0 0x{{.*}} in {{.*}}free
-  // MALLOC-CTX: #{{[1-3]}} 0x{{.*}} in main {{.*}}double-free.cpp:[[@LINE-7]]
+  // MALLOC-CTX: #{{[0-9]+}} 0x{{.*}} in main {{.*}}double-free.cpp:[[@LINE-7]]
   // CHECK: allocated by thread T0 here:
   // MALLOC-CTX: double-free.cpp:[[@LINE-12]]
   // CHECK-RECOVER: AddressSanitizer: attempting double-free{{.*}}in thread T0
diff --git a/compiler-rt/test/asan/TestCases/malloc-size-too-big.cpp b/compiler-rt/test/asan/TestCases/malloc-size-too-big.cpp
index 771640a4ac08d..3906ff5057fd8 100644
--- a/compiler-rt/test/asan/TestCases/malloc-size-too-big.cpp
+++ b/compiler-rt/test/asan/TestCases/malloc-size-too-big.cpp
@@ -17,8 +17,8 @@ static const size_t kMaxAllowedMallocSizePlusOne =
 int main() {
   void *p = malloc(kMaxAllowedMallocSizePlusOne);
   // CHECK: {{ERROR: AddressSanitizer: requested allocation size .* \(.* after adjustments for alignment, red zones etc\.\) exceeds maximum supported size}}
-  // CHECK: {{#0 0x.* in .*malloc}}
-  // CHECK: {{#[1-3] 0x.* in main .*malloc-size-too-big.cpp:}}[[@LINE-3]]
+  // CHECK: {{#[0-9] 0x.* in .*malloc}}
+  // CHECK: {{#[0-9] 0x.* in main .*malloc-size-too-big.cpp:}}[[@LINE-3]]
   // CHECK: SUMMARY: AddressSanitizer: allocation-size-too-big
 
   printf("malloc returned: %zu\n", (size_t)p);
diff --git a/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp b/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp
index efd2e6b7521ef..235b758f681c5 100644
--- a/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp
+++ b/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp
@@ -36,9 +36,9 @@ __attribute__((noinline)) void bad_function() {
   char buffer[] = "hello";
   // CHECK: strcpy-param-overlap: memory ranges
   // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap
-  // CHECK: {{#0 0x.* in .*strcpy}}
-  // CHECK: {{#1 0x.* in bad_function.*strcpy-overlap.cpp:}}[[@LINE+2]]
-  // CHECK: {{#2 0x.* in main .*strcpy-overlap.cpp:}}[[@LINE+5]]
+  // CHECK: {{#[0-9]+ 0x.* in .*strcpy}}
+  // CHECK: {{#[0-9]+ 0x.* in bad_function.*strcpy-overlap.cpp:}}[[@LINE+2]]
+  // CHECK: {{#[0-9]+ 0x.* in main .*strcpy-overlap.cpp:}}[[@LINE+5]]
   strcpy(buffer, buffer + 1); // BOOM
 }
 
diff --git a/compiler-rt/test/asan/TestCases/strdup_oob_test.cpp b/compiler-rt/test/asan/TestCases/strdup_oob_test.cpp
index 14791e46d3a95..c3cbcf3bcf544 100644
--- a/compiler-rt/test/asan/TestCases/strdup_oob_test.cpp
+++ b/compiler-rt/test/asan/TestCases/strdup_oob_test.cpp
@@ -23,7 +23,7 @@ int main(int argc, char **argv) {
   // CHECK: AddressSanitizer: heap-buffer-overflow
   // CHECK: #0 {{.*}}main {{.*}}strdup_oob_test.cpp:[[@LINE-2]]
   // CHECK-LABEL: allocated by thread T{{.*}} here:
-  // CHECK: #{{[01]}} {{.*}}strdup
+  // CHECK: #{{[0-9]}}+ {{.*}}strdup
   // CHECK: #{{.*}}main {{.*}}strdup_oob_test.cpp:[[@LINE-6]]
   // CHECK-LABEL: SUMMARY
   // CHECK: strdup_oob_test.cpp:[[@LINE-7]]
diff --git a/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp b/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
index ff84052a94987..cb22235f0c20a 100644
--- a/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
+++ b/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
@@ -28,11 +28,11 @@ int main(int argc, char **argv) {
   char *short_buffer = (char*)malloc(9);
   strncpy(short_buffer, hello, 10);  // BOOM
   // CHECK: {{WRITE of size 10 at 0x.* thread T0}}
-  // CHECK: {{    #0 0x.* in .*strncpy}}
-  // CHECK: {{    #1 0x.* in main .*strncpy-overflow.cpp:}}[[@LINE-3]]
+  // CHECK: {{    #[0-9]+ 0x.* in .*strncpy}}
+  // CHECK: {{    #[0-9]+ 0x.* in main .*strncpy-overflow.cpp:}}[[@LINE-3]]
   // CHECK: {{0x.* is located 0 bytes after 9-byte region}}
   // CHECK: {{allocated by thread T0 here:}}
-  // CHECK: {{    #0 0x.* in .*malloc}}
-  // CHECK: {{    #[1-3] 0x.* in main .*strncpy-overflow.cpp:}}[[@LINE-8]]
+  // CHECK: {{    #[0-9]+ 0x.* in .*malloc}}
+  // CHECK: {{    #[0-9]+ 0x.* in main .*strncpy-overflow.cpp:}}[[@LINE-8]]
   return rval + sink_memory(9, short_buffer);
 }
diff --git a/compiler-rt/test/asan/TestCases/use-after-free-right.cpp b/compiler-rt/test/asan/TestCases/use-after-free-right.cpp
index 11011e4b4fb1a..2f4b4d878e547 100644
--- a/compiler-rt/test/asan/TestCases/use-after-free-right.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-free-right.cpp
@@ -15,13 +15,13 @@ int main() {
   // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
   // CHECK:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
   // CHECK: {{WRITE of size 1 at 0x.* thread T0}}
-  // CHECK: {{    #0 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-4]]
+  // CHECK: {{    #[0-9]+ 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-4]]
   // CHECK: {{0x.* is located 0 bytes inside of 1-byte region .0x.*,0x.*}}
   // CHECK: {{freed by thread T0 here:}}
-  // CHECK: {{    #0 0x.* in .*free}}
-  // CHECK: {{    #[1-3] 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-9]]
+  // CHECK: {{    #[0-9]+ 0x.* in .*free}}
+  // CHECK: {{    #[0-9]+ 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-9]]
 
   // CHECK: {{previously allocated by thread T0 here:}}
-  // CHECK: {{    #0 0x.* in .*malloc}}
-  // CHECK: {{    #[1-3] 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-14]]
+  // CHECK: {{    #[0-9]+ 0x.* in .*malloc}}
+  // CHECK: {{    #[0-9]+ 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-14]]
 }
diff --git a/compiler-rt/test/asan/TestCases/use-after-free.cpp b/compiler-rt/test/asan/TestCases/use-after-free.cpp
index f19c461960d36..d54caef14fb9f 100644
--- a/compiler-rt/test/asan/TestCases/use-after-free.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-free.cpp
@@ -12,15 +12,15 @@ int main() {
   // 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.* in main .*use-after-free.cpp:}}[[@LINE-4]]
+  // CHECK: {{    #[0-9]+ 0x.* in main .*use-after-free.cpp:}}[[@LINE-4]]
   // CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
   // CHECK: {{freed by thread T0 here:}}
-  // CHECK: {{    #0 0x.* in .*free}}
-  // CHECK: {{    #[1-3] 0x.* in main .*use-after-free.cpp:}}[[@LINE-9]]
+  // CHECK: {{    #[0-9]+ 0x.* in .*free}}
+  // CHECK: {{    #[0-9]+ 0x.* in main .*use-after-free.cpp:}}[[@LINE-9]]
 
   // CHECK: {{previously allocated by thread T0 here:}}
-  // CHECK: {{    #0 0x.* in .*malloc}}
-  // CHECK: {{    #[1-3] 0x.* in main .*use-after-free.cpp:}}[[@LINE-14]]
+  // CHECK: {{    #[0-9]+ 0x.* in .*malloc}}
+  // CHECK: {{    #[0-9]+ 0x.* in main .*use-after-free.cpp:}}[[@LINE-14]]
   // CHECK: Shadow byte legend (one shadow byte represents {{[0-9]+}} application bytes):
   // CHECK: Global redzone:
   // CHECK: ASan internal:



More information about the llvm-commits mailing list