mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-01 08:12:12 +00:00
[libFuzzer] don't report memory leaks if we are dying due to a timeout (just use _Exit instead of exit in the timeout callback)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264237 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f4b00d0631
commit
c09d592889
@ -164,7 +164,7 @@ void Fuzzer::AlarmCallback() {
|
||||
__sanitizer_print_stack_trace();
|
||||
Printf("SUMMARY: libFuzzer: timeout\n");
|
||||
PrintFinalStats();
|
||||
exit(Options.TimeoutExitCode);
|
||||
_Exit(Options.TimeoutExitCode); // Stop right now.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ set(Tests
|
||||
InitializeTest
|
||||
MemcmpTest
|
||||
LeakTest
|
||||
LeakTimeoutTest
|
||||
NullDerefTest
|
||||
NthRunCrashTest
|
||||
RepeatedMemcmp
|
||||
|
14
lib/Fuzzer/test/LeakTimeoutTest.cpp
Normal file
14
lib/Fuzzer/test/LeakTimeoutTest.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Test with a leak.
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
static volatile int *Sink;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
if (!Size) return 0;
|
||||
Sink = new int;
|
||||
Sink = new int;
|
||||
while (Sink) *Sink = 0; // Infinite loop.
|
||||
return 0;
|
||||
}
|
||||
|
9
lib/Fuzzer/test/fuzzer-leak.test
Normal file
9
lib/Fuzzer/test/fuzzer-leak.test
Normal file
@ -0,0 +1,9 @@
|
||||
RUN: not LLVMFuzzer-LeakTest -runs=10 2>&1 | FileCheck %s --check-prefix=LEAK
|
||||
LEAK: ERROR: LeakSanitizer: detected memory leaks
|
||||
LEAK-NOT: DEATH:
|
||||
|
||||
RUN: not LLVMFuzzer-LeakTimeoutTest -timeout=1 2>&1 | FileCheck %s --check-prefix=LEAK_TIMEOUT
|
||||
LEAK_TIMEOUT: ERROR: libFuzzer: timeout after
|
||||
LEAK_TIMEOUT-NOT: LeakSanitizer
|
||||
|
||||
|
@ -69,10 +69,6 @@ RUN: LLVMFuzzer-SimpleTest %t/SUB1 -runs=0 2>&1 | FileCheck %s --check-prefix=SU
|
||||
SUBDIRS: READ units: 3
|
||||
RUN: rm -rf %t/SUB1
|
||||
|
||||
RUN: not LLVMFuzzer-LeakTest -runs=10 2>&1 | FileCheck %s --check-prefix=LEAK
|
||||
LEAK: ERROR: LeakSanitizer: detected memory leaks
|
||||
LEAK-NOT: DEATH:
|
||||
|
||||
RUN: mkdir -p %t
|
||||
RUN: echo abcd > %t/NthRunCrashTest.in
|
||||
RUN: LLVMFuzzer-NthRunCrashTest %t/NthRunCrashTest.in
|
||||
|
Loading…
x
Reference in New Issue
Block a user