1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[libFuzzer] print a stack trace on timeout

llvm-svn: 250571
This commit is contained in:
Kostya Serebryany 2015-10-16 23:04:31 +00:00
parent 4393ca2076
commit a51be6eaa4
4 changed files with 17 additions and 0 deletions

View File

@ -56,6 +56,7 @@ bool ToASCII(Unit &U);
bool IsASCII(const Unit &U); bool IsASCII(const Unit &U);
int NumberOfCpuCores(); int NumberOfCpuCores();
int GetPid();
// Dictionary. // Dictionary.

View File

@ -13,6 +13,10 @@
#include <sanitizer/coverage_interface.h> #include <sanitizer/coverage_interface.h>
#include <algorithm> #include <algorithm>
extern "C" {
__attribute__((weak)) void __sanitizer_print_stack_trace();
}
namespace fuzzer { namespace fuzzer {
static const size_t kMaxUnitSizeToPrint = 256; static const size_t kMaxUnitSizeToPrint = 256;
@ -76,6 +80,11 @@ void Fuzzer::AlarmCallback() {
PrintUnitInASCIIOrTokens(CurrentUnit, "\n"); PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
} }
WriteUnitToFileWithPrefix(CurrentUnit, "timeout-"); WriteUnitToFileWithPrefix(CurrentUnit, "timeout-");
Printf("==%d== ERROR: libFuzzer: timeout after %d seconds\n", GetPid(),
Seconds);
if (__sanitizer_print_stack_trace)
__sanitizer_print_stack_trace();
Printf("SUMMARY: libFuzzer: timeout\n");
exit(1); exit(1);
} }
} }

View File

@ -166,4 +166,6 @@ bool ParseDictionaryFile(const std::string &Text, std::vector<Unit> *Units) {
return true; return true;
} }
int GetPid() { return getpid(); }
} // namespace fuzzer } // namespace fuzzer

View File

@ -14,6 +14,11 @@ MaxTotalTime: Done {{.*}} runs in {{.}} second(s)
RUN: not LLVMFuzzer-TimeoutTest -timeout=5 2>&1 | FileCheck %s --check-prefix=TimeoutTest RUN: not LLVMFuzzer-TimeoutTest -timeout=5 2>&1 | FileCheck %s --check-prefix=TimeoutTest
TimeoutTest: ALARM: working on the last Unit for TimeoutTest: ALARM: working on the last Unit for
TimeoutTest: Test unit written to ./timeout- TimeoutTest: Test unit written to ./timeout-
TimeoutTest: == ERROR: libFuzzer: timeout after
TimeoutTest: #0
TimeoutTest: #1
TimeoutTest: #2
TimeoutTest: SUMMARY: libFuzzer: timeout
RUN: not LLVMFuzzer-TimeoutTest -timeout=5 -test_single_input=%S/hi.txt 2>&1 | FileCheck %s --check-prefix=SingleInputTimeoutTest RUN: not LLVMFuzzer-TimeoutTest -timeout=5 -test_single_input=%S/hi.txt 2>&1 | FileCheck %s --check-prefix=SingleInputTimeoutTest
SingleInputTimeoutTest: ALARM: working on the last Unit for SingleInputTimeoutTest: ALARM: working on the last Unit for