[llvm] r250571 - [libFuzzer] print a stack trace on timeout
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 16 16:04:31 PDT 2015
Author: kcc
Date: Fri Oct 16 18:04:31 2015
New Revision: 250571
URL: http://llvm.org/viewvc/llvm-project?rev=250571&view=rev
Log:
[libFuzzer] print a stack trace on timeout
Modified:
llvm/trunk/lib/Fuzzer/FuzzerInternal.h
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp
llvm/trunk/lib/Fuzzer/test/fuzzer.test
Modified: llvm/trunk/lib/Fuzzer/FuzzerInternal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerInternal.h?rev=250571&r1=250570&r2=250571&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerInternal.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerInternal.h Fri Oct 16 18:04:31 2015
@@ -56,6 +56,7 @@ bool ToASCII(Unit &U);
bool IsASCII(const Unit &U);
int NumberOfCpuCores();
+int GetPid();
// Dictionary.
Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=250571&r1=250570&r2=250571&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Fri Oct 16 18:04:31 2015
@@ -13,6 +13,10 @@
#include <sanitizer/coverage_interface.h>
#include <algorithm>
+extern "C" {
+__attribute__((weak)) void __sanitizer_print_stack_trace();
+}
+
namespace fuzzer {
static const size_t kMaxUnitSizeToPrint = 256;
@@ -76,6 +80,11 @@ void Fuzzer::AlarmCallback() {
PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
}
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);
}
}
Modified: llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp?rev=250571&r1=250570&r2=250571&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp Fri Oct 16 18:04:31 2015
@@ -166,4 +166,6 @@ bool ParseDictionaryFile(const std::stri
return true;
}
+int GetPid() { return getpid(); }
+
} // namespace fuzzer
Modified: llvm/trunk/lib/Fuzzer/test/fuzzer.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/fuzzer.test?rev=250571&r1=250570&r2=250571&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/fuzzer.test (original)
+++ llvm/trunk/lib/Fuzzer/test/fuzzer.test Fri Oct 16 18:04:31 2015
@@ -14,6 +14,11 @@ MaxTotalTime: Done {{.*}} runs in {{.}}
RUN: not LLVMFuzzer-TimeoutTest -timeout=5 2>&1 | FileCheck %s --check-prefix=TimeoutTest
TimeoutTest: ALARM: working on the last Unit for
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
SingleInputTimeoutTest: ALARM: working on the last Unit for
More information about the llvm-commits
mailing list