Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fuzztest/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ cc_library(
":serialization",
":status",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/cleanup",
"@abseil-cpp//absl/functional:any_invocable",
"@abseil-cpp//absl/functional:bind_front",
"@abseil-cpp//absl/functional:function_ref",
Expand Down
1 change: 1 addition & 0 deletions fuzztest/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ fuzztest_cc_library(
fuzztest::sanitizer_interface
fuzztest::serialization
fuzztest::status
absl::cleanup
absl::core_headers
absl::any_invocable
absl::bind_front
Expand Down
1 change: 1 addition & 0 deletions fuzztest/internal/googletest_adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class GTest_TestAdaptor : public ::testing::Test {
EXPECT_TRUE(test->RunInFuzzingMode(argc_, argv_, configuration_))
<< "Failure(s) found in the fuzzing mode.";
}
EXPECT_FALSE(Runtime::instance().external_failure_detected());
}

static void SetUpTestSuite() {
Expand Down
11 changes: 10 additions & 1 deletion fuzztest/internal/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <utility>
#include <vector>

#include "absl/cleanup/cleanup.h"
#include "absl/functional/bind_front.h"
#include "absl/functional/function_ref.h"
#include "absl/random/bit_gen_ref.h"
Expand Down Expand Up @@ -576,6 +577,10 @@ static void HandleCrash(int signum, siginfo_t* info, void* ucontext) {
if (!has_old_handler || signum != SIGTRAP ||
(info->si_code != TRAP_PERF && info->si_code != SI_TIMER)) {
// Dump our info first.
absl::Format(&signal_out_sink,
"[!] Reporting crashing signal %d as an external failure.\n",
signum);
runtime.SetExternalFailureDetected(true);
runtime.PrintReport(&signal_out_sink);
// The old signal handler might print important messages (e.g., strack
// trace) to the original file descriptors, therefore we restore them before
Expand All @@ -597,7 +602,7 @@ static void HandleCrash(int signum, siginfo_t* info, void* ucontext) {
raise(signum);
absl::Format(&signal_out_sink,
"[!] The default action of crashing signal %d did not crash - "
"aborting",
"aborting\n",
signum);
// At this point abort should be fine even if signum == SIGABRT.
std::abort();
Expand Down Expand Up @@ -751,7 +756,11 @@ bool FuzzTestFuzzerImpl::ReplayInputsIfAvailable(
const Configuration& configuration) {
// Crashing inputs are discovered in fuzzing mode. To increase the chance of
// reproducing the crash, fuzzing mode should be used.
const auto old_run_mode = runtime_.run_mode();
runtime_.SetRunMode(RunMode::kFuzz);
absl::Cleanup restore_run_mode = [this, old_run_mode]() {
runtime_.SetRunMode(old_run_mode);
};

auto replay_input = absl::bind_front(&FuzzTestFuzzerImpl::ReplayInput, this);
if (const auto file_paths = GetFilesToReplay()) {
Expand Down
Loading