Skip to content

Commit 3754fc1

Browse files
authored
[hwasan] Flush stderr/stdout in tests (#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.
1 parent a18af41 commit 3754fc1

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

compiler-rt/test/hwasan/TestCases/many-threads-uaf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void *BoringThread(void *arg) {
2323
void *UAFThread(void *arg) {
2424
char * volatile x = (char*)malloc(10);
2525
fprintf(stderr, "ZZZ %p\n", x);
26+
fflush(stderr);
2627
free(x);
2728
x[5] = 42;
2829
// CHECK: ERROR: HWAddressSanitizer: tag-mismatch on address

compiler-rt/test/hwasan/TestCases/mem-intrinsics.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ int main() {
2121
memcpy(Q, P, 32);
2222
#endif
2323
write(STDOUT_FILENO, "recovered\n", 10);
24+
fflush(stdout);
2425
// WRITE: ERROR: HWAddressSanitizer: tag-mismatch on address
2526
// WRITE: WRITE of size 32 at {{.*}} tags: [[PTR_TAG:..]]/[[MEM_TAG:..]] (ptr/mem)
2627
// WRITE: Invalid access starting at offset 16

compiler-rt/test/hwasan/TestCases/use-after-free.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ int main() {
1515
free(x);
1616
__hwasan_disable_allocator_tagging();
1717
fprintf(stderr, ISREAD ? "Going to do a READ\n" : "Going to do a WRITE\n");
18+
fflush(stderr);
1819
// CHECK: Going to do a [[TYPE:[A-Z]*]]
1920
int r = 0;
2021
if (ISREAD) r = x[5]; else x[5] = 42; // should be on the same line.

0 commit comments

Comments
 (0)