mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 04:09:45 +00:00
[libFuzzer] use __sanitizer_set_report_fd with -close_fd_mask. This allows us to keep asan reports when closing target's stderr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271053 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a31d45bb57
commit
dc4065fcc1
@ -273,9 +273,8 @@ The most important command line options are:
|
||||
If 1 (default) and if LeakSanitizer is enabled
|
||||
try to detect memory leaks during fuzzing (i.e. not only at shut down).
|
||||
``-close_fd_mask``
|
||||
Indicate output streams to close at startup. Be careful, this will also
|
||||
remove diagnostic output from the tools in use; for example the messages
|
||||
AddressSanitizer_ sends to ``stderr``/``stdout`` will also be lost.
|
||||
Indicate output streams to close at startup. Be careful, this will
|
||||
remove diagnostic output from target code (e.g. messages on assert failure).
|
||||
|
||||
- 0 (default): close neither ``stdout`` nor ``stderr``
|
||||
- 1 : close ``stdout``
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ RUN: LLVMFuzzer-SimpleTest -only_ascii=1 2>&1
|
||||
RUN: LLVMFuzzer-SimpleCmpTest -max_total_time=1 2>&1 | FileCheck %s --check-prefix=MaxTotalTime
|
||||
MaxTotalTime: Done {{.*}} runs in {{.}} second(s)
|
||||
|
||||
RUN: not LLVMFuzzer-NullDerefTest 2>&1 | FileCheck %s --check-prefix=NullDerefTest
|
||||
RUN: not LLVMFuzzer-NullDerefTest 2>&1 | FileCheck %s --check-prefix=NullDerefTest
|
||||
RUN: not LLVMFuzzer-NullDerefTest -close_fd_mask=3 2>&1 | FileCheck %s --check-prefix=NullDerefTest
|
||||
NullDerefTest: ERROR: AddressSanitizer: SEGV on unknown address
|
||||
NullDerefTest: Test unit written to ./crash-
|
||||
RUN: not LLVMFuzzer-NullDerefTest -artifact_prefix=ZZZ 2>&1 | FileCheck %s --check-prefix=NullDerefTestPrefix
|
||||
NullDerefTestPrefix: Test unit written to ZZZcrash-
|
||||
|
Loading…
Reference in New Issue
Block a user