Skip to content

[asan] Flush stderr in test #114084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2024
Merged

[asan] Flush stderr in test #114084

merged 1 commit into from
Oct 29, 2024

Conversation

thurstond
Copy link
Contributor

@thurstond thurstond commented Oct 29, 2024

This is the ASan equivalent of #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 ASan check is correct but it did not match the stderr/stdout output. This patch attempts to fix the issue by flushing stderr as appropriate.

This is the ASan equivalent of llvm#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.
@llvmbot
Copy link
Member

llvmbot commented Oct 29, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Thurston Dang (thurstond)

Changes

This is the ASan equivalent of #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 ASan 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.


Full diff: https://github.com/llvm/llvm-project/pull/114084.diff

1 Files Affected:

  • (modified) compiler-rt/test/asan/TestCases/Posix/ignore_free_hook.cpp (+4-1)
diff --git a/compiler-rt/test/asan/TestCases/Posix/ignore_free_hook.cpp b/compiler-rt/test/asan/TestCases/Posix/ignore_free_hook.cpp
index 87be90014d56e8..dfeb8ad5c7b53f 100644
--- a/compiler-rt/test/asan/TestCases/Posix/ignore_free_hook.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/ignore_free_hook.cpp
@@ -26,14 +26,17 @@ bool ignore_free = false;
 
 extern "C" {
 WEAK_ON_APPLE void __sanitizer_free_hook(const volatile void *ptr) {
-  if (ptr == glob_ptr)
+  if (ptr == glob_ptr) {
     fprintf(stderr, "Free Hook\n");
+    fflush(stderr);
+  }
 }
 
 WEAK_ON_APPLE int __sanitizer_ignore_free_hook(const volatile void *ptr) {
   if (ptr != glob_ptr)
     return 0;
   fprintf(stderr, ignore_free ? "Free Ignored\n" : "Free Respected\n");
+  fflush(stderr);
   return ignore_free;
 }
 } // extern "C"

@thurstond thurstond changed the title [asan] Flush stderr/stdout in tests [asan] Flush stderr in test Oct 29, 2024
@fmayer
Copy link
Contributor

fmayer commented Oct 29, 2024

Shouldn't stderr be unbuffered?

@thurstond
Copy link
Contributor Author

Shouldn't stderr be unbuffered?

Hmm, that's a good point. Should I still merge to see if it works around the QEMU issue?

@fmayer
Copy link
Contributor

fmayer commented Oct 29, 2024

Shouldn't stderr be unbuffered?

Hmm, that's a good point. Should I still merge to see if it works around the QEMU issue?

I'm not opposed. Could this be a qemu bug?

@thurstond thurstond merged commit e205929 into llvm:main Oct 29, 2024
11 checks passed
@thurstond
Copy link
Contributor Author

Shouldn't stderr be unbuffered?

Hmm, that's a good point. Should I still merge to see if it works around the QEMU issue?

I'm not opposed. Could this be a qemu bug?

Looks like this patch did not solve the QEMU bot issues: https://lab.llvm.org/buildbot/#/builders/139/builds/5552/steps/30/logs/stdio

"A bug? In QEMU code?
It's more likely than you think.
FREE PC EMULATOR!"

@fmayer
Copy link
Contributor

fmayer commented Oct 29, 2024

Shouldn't stderr be unbuffered?

Hmm, that's a good point. Should I still merge to see if it works around the QEMU issue?

I'm not opposed. Could this be a qemu bug?

Looks like this patch did not solve the QEMU bot issues: https://lab.llvm.org/buildbot/#/builders/139/builds/5552/steps/30/logs/stdio

"A bug? In QEMU code? It's more likely than you think. FREE PC EMULATOR!"

Let's revert then?

thurstond added a commit that referenced this pull request Oct 29, 2024
This reverts commit e205929.

Reason: did not solve the QEMU bot issues (https://lab.llvm.org/buildbot/#/builders/139/builds/5552/steps/30/logs/stdio) and it shouldn't have been necessary anyway (#114084 (comment))
@thurstond
Copy link
Contributor Author

Let's revert then?

Done. Big Corporate strikes again.

NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
This is the ASan equivalent of
llvm#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 ASan check is correct but it did not
match the stderr/stdout output. This patch attempts to fix the issue by
flushing stderr as appropriate.
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
This reverts commit e205929.

Reason: did not solve the QEMU bot issues (https://lab.llvm.org/buildbot/#/builders/139/builds/5552/steps/30/logs/stdio) and it shouldn't have been necessary anyway (llvm#114084 (comment))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants