summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerTracePC.cpp4
-rw-r--r--compiler-rt/test/fuzzer/deep-recursion.test4
2 files changed, 7 insertions, 1 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
index ebd33d3ec88..985649a803b 100644
--- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
@@ -343,8 +343,10 @@ void TracePC::ClearInlineCounters() {
}
}
+ATTRIBUTE_NO_SANITIZE_ALL
void TracePC::RecordInitialStack() {
- InitialStack = __sancov_lowest_stack;
+ int stack;
+ __sancov_lowest_stack = InitialStack = reinterpret_cast<uintptr_t>(&stack);
}
uintptr_t TracePC::GetMaxStackOffset() const {
diff --git a/compiler-rt/test/fuzzer/deep-recursion.test b/compiler-rt/test/fuzzer/deep-recursion.test
new file mode 100644
index 00000000000..23b7af1df38
--- /dev/null
+++ b/compiler-rt/test/fuzzer/deep-recursion.test
@@ -0,0 +1,4 @@
+# Test that we can find a stack overflow
+RUN: %cpp_compiler -fsanitize-coverage=stack-depth %S/DeepRecursionTest.cpp -o %t
+RUN: not %t -seed=1 -runs=100000000 2>&1 | FileCheck %s
+CHECK: ERROR: libFuzzer: deadly signal
OpenPOWER on IntegriCloud