Files
clang-p2996/compiler-rt/test/fuzzer/AcquireCrashStateTest.cpp
Matt Morehouse 52fd169035 [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

llvm-svn: 331310
2018-05-01 21:01:53 +00:00

19 lines
547 B
C++

// 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.
}