[compiler-rt] [hwasan] Flush stderr/stdout in tests (PR #114083)
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 09:32:06 PDT 2024
https://github.com/thurstond created https://github.com/llvm/llvm-project/pull/114083
The x86_64_lam_qemu buildbots started failing (https://lab.llvm.org/buildbot/#/builders/139/builds/5462/steps/2/logs/stdio). Based on the logs, it appears the HWASan check is correct but it did not match the stderr/stdout output. This patch attempts to fix the issue by flushing stderr/stdout as appropriate.
>From c46703c78eef14a216a5a5528d134e9469a44a9d Mon Sep 17 00:00:00 2001
From: Thurston Dang <thurston at google.com>
Date: Tue, 29 Oct 2024 16:27:54 +0000
Subject: [PATCH] [hwasan] Flush stderr/stdout in tests
The x86_64_lam_qemu buildbots started failing (https://lab.llvm.org/buildbot/#/builders/139/builds/5462/steps/2/logs/stdio). Based on the logs, it appears the HWASan check is correct but it did not match the stderr/stdout output. This patch attempts to fix the issue by flushing stderr/stdout as appropriate.
---
compiler-rt/test/hwasan/TestCases/many-threads-uaf.c | 1 +
compiler-rt/test/hwasan/TestCases/mem-intrinsics.c | 1 +
compiler-rt/test/hwasan/TestCases/use-after-free.c | 1 +
3 files changed, 3 insertions(+)
diff --git a/compiler-rt/test/hwasan/TestCases/many-threads-uaf.c b/compiler-rt/test/hwasan/TestCases/many-threads-uaf.c
index 8fa07861371d56..e02ab5b28ce046 100644
--- a/compiler-rt/test/hwasan/TestCases/many-threads-uaf.c
+++ b/compiler-rt/test/hwasan/TestCases/many-threads-uaf.c
@@ -23,6 +23,7 @@ void *BoringThread(void *arg) {
void *UAFThread(void *arg) {
char * volatile x = (char*)malloc(10);
fprintf(stderr, "ZZZ %p\n", x);
+ fflush(stderr);
free(x);
x[5] = 42;
// CHECK: ERROR: HWAddressSanitizer: tag-mismatch on address
diff --git a/compiler-rt/test/hwasan/TestCases/mem-intrinsics.c b/compiler-rt/test/hwasan/TestCases/mem-intrinsics.c
index 78bef538af1161..da1cb686969206 100644
--- a/compiler-rt/test/hwasan/TestCases/mem-intrinsics.c
+++ b/compiler-rt/test/hwasan/TestCases/mem-intrinsics.c
@@ -21,6 +21,7 @@ int main() {
memcpy(Q, P, 32);
#endif
write(STDOUT_FILENO, "recovered\n", 10);
+ fflush(stdout);
// WRITE: ERROR: HWAddressSanitizer: tag-mismatch on address
// WRITE: WRITE of size 32 at {{.*}} tags: [[PTR_TAG:..]]/[[MEM_TAG:..]] (ptr/mem)
// WRITE: Invalid access starting at offset 16
diff --git a/compiler-rt/test/hwasan/TestCases/use-after-free.c b/compiler-rt/test/hwasan/TestCases/use-after-free.c
index 070622f560a225..b4b79875e8111e 100644
--- a/compiler-rt/test/hwasan/TestCases/use-after-free.c
+++ b/compiler-rt/test/hwasan/TestCases/use-after-free.c
@@ -15,6 +15,7 @@ int main() {
free(x);
__hwasan_disable_allocator_tagging();
fprintf(stderr, ISREAD ? "Going to do a READ\n" : "Going to do a WRITE\n");
+ fflush(stderr);
// CHECK: Going to do a [[TYPE:[A-Z]*]]
int r = 0;
if (ISREAD) r = x[5]; else x[5] = 42; // should be on the same line.
More information about the llvm-commits
mailing list