[compiler-rt] [HWASan] add test for hwasan_symbolize of stack uas (PR #95186)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 11:01:52 PDT 2024


https://github.com/fmayer updated https://github.com/llvm/llvm-project/pull/95186

>From c56ab852b9eb70b83c1c14b93dc653892682ca84 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Tue, 11 Jun 2024 18:16:17 -0700
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../TestCases/hwasan_symbolize_stack_uas.cpp  | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp

diff --git a/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp b/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp
new file mode 100644
index 0000000000000..a88f12aaa6a9f
--- /dev/null
+++ b/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_hwasan -Wl,--build-id -g %s -o %t
+// RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | hwasan_symbolize --symbols $(dirname %t) --index | FileCheck %s
+
+#include <sanitizer/hwasan_interface.h>
+#include <stdlib.h>
+
+static volatile char sink;
+
+int main(int argc, char **argv) {
+  volatile char* y;
+  {
+    volatile char x[10];
+    y = &x[0];
+  }
+  sink = *y;
+  // CHECK: Potentially referenced stack object:
+  // CHECK:   0 bytes inside a variable "x" in stack frame of function "main"
+  // CHECK:   at {{.*}}hwasan_symbolize_stack_uas.cpp:[[@LINE-6]]
+  return 0;
+}

>From 8b856ff374d080d283d762030fd87f873f85899d Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Tue, 11 Jun 2024 18:20:12 -0700
Subject: [PATCH 2/3] fmt

Created using spr 1.3.4
---
 .../test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp b/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp
index a88f12aaa6a9f..3d633e66f1d59 100644
--- a/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp
+++ b/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp
@@ -7,7 +7,7 @@
 static volatile char sink;
 
 int main(int argc, char **argv) {
-  volatile char* y;
+  volatile char *y;
   {
     volatile char x[10];
     y = &x[0];

>From 335bea5b5b5e4f07ebb6977263c2985565f17398 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Wed, 12 Jun 2024 11:01:39 -0700
Subject: [PATCH 3/3] restrict test

Created using spr 1.3.4
---
 .../test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp      | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp b/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp
index 3d633e66f1d59..8be71749f54bb 100644
--- a/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp
+++ b/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_hwasan -Wl,--build-id -g %s -o %t
-// RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | hwasan_symbolize --symbols $(dirname %t) --index | FileCheck %s
+// RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | tee /tmp/stuff2  | hwasan_symbolize --symbols $(dirname %t) --index | FileCheck %s
+
+// REQUIRES: pointer-tagging
 
 #include <sanitizer/hwasan_interface.h>
 #include <stdlib.h>



More information about the llvm-commits mailing list