summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerIO.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-05-27 21:46:22 +0000
committerKostya Serebryany <kcc@google.com>2016-05-27 21:46:22 +0000
commit470d04400e0caf6ba915ba8117a7c2ca8e10d9d4 (patch)
tree0ecd1603f75413c286a31eb10b302678b79606aa /llvm/lib/Fuzzer/FuzzerIO.cpp
parentf9bda6805be8b4908e22ca9777a4b71b329ba381 (diff)
downloadbcm5719-llvm-470d04400e0caf6ba915ba8117a7c2ca8e10d9d4.tar.gz
bcm5719-llvm-470d04400e0caf6ba915ba8117a7c2ca8e10d9d4.zip
[libFuzzer] use __sanitizer_set_report_fd with -close_fd_mask. This allows us to keep asan reports when closing target's stderr
llvm-svn: 271053
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerIO.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerIO.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerIO.cpp b/llvm/lib/Fuzzer/FuzzerIO.cpp
index ac35d736bbf..171b188eab5 100644
--- a/llvm/lib/Fuzzer/FuzzerIO.cpp
+++ b/llvm/lib/Fuzzer/FuzzerIO.cpp
@@ -18,6 +18,10 @@
#include <cstdarg>
#include <cstdio>
+extern "C" {
+__attribute__((weak)) void __sanitizer_set_report_fd(void *);
+}
+
namespace fuzzer {
static FILE *OutputFile = stderr;
@@ -122,6 +126,8 @@ void DupAndCloseStderr() {
FILE *NewOutputFile = fdopen(OutputFd, "w");
if (NewOutputFile) {
OutputFile = NewOutputFile;
+ if (__sanitizer_set_report_fd)
+ __sanitizer_set_report_fd(reinterpret_cast<void*>(OutputFd));
close(2);
}
}
OpenPOWER on IntegriCloud