aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatt Morehouse <mascasa@google.com>2018-05-01 21:01:53 +0000
committerMatt Morehouse <mascasa@google.com>2018-05-01 21:01:53 +0000
commit42ed860e35e7d30dc37b5dd548eeb7b1cb5dd902 (patch)
treeccb5e69be4a71d5f0cc03def1d2487009b4f0129 /test
parentdcd249132f2d06fb3209b0f965ad1b09ef61feb0 (diff)
[libFuzzer] Report at most one crash per input.
Summary: Fixes https://github.com/google/sanitizers/issues/788/, a deadlock caused by multiple crashes happening at the same time. Before printing a crash report, we now test and set an atomic flag. If the flag was already set, the crash handler returns immediately. Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D46277 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@331310 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/fuzzer/AcquireCrashStateTest.cpp18
-rw-r--r--test/fuzzer/acquire-crash-state.test3
2 files changed, 21 insertions, 0 deletions
diff --git a/test/fuzzer/AcquireCrashStateTest.cpp b/test/fuzzer/AcquireCrashStateTest.cpp
new file mode 100644
index 000000000..0fe71fd46
--- /dev/null
+++ b/test/fuzzer/AcquireCrashStateTest.cpp
@@ -0,0 +1,18 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+// Ensures that error reports are suppressed after
+// __sanitizer_acquire_crash_state() has been called the first time.
+#include "sanitizer/common_interface_defs.h"
+
+#include <cassert>
+#include <cstdint>
+#include <cstdlib>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ assert(Data);
+ if (Size == 0) return 0;
+ __sanitizer_acquire_crash_state();
+ exit(0); // No report should be generated here.
+}
+
diff --git a/test/fuzzer/acquire-crash-state.test b/test/fuzzer/acquire-crash-state.test
new file mode 100644
index 000000000..db893df90
--- /dev/null
+++ b/test/fuzzer/acquire-crash-state.test
@@ -0,0 +1,3 @@
+RUN: %cpp_compiler %S/AcquireCrashStateTest.cpp -o %t
+RUN: %t 2>&1 | FileCheck %s
+CHECK-NOT: fuzz target exited