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 @@ -416,6 +416,7 @@ cc_library(
"@abseil-cpp//absl/status:statusor",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/synchronization",
"@abseil-cpp//absl/time",
"@abseil-cpp//absl/types:span",
"@com_google_fuzztest//common:bazel",
Expand Down
1 change: 1 addition & 0 deletions fuzztest/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ fuzztest_cc_library(
absl::statusor
absl::strings
absl::str_format
absl::synchronization
absl::time
absl::span
fuzztest::bazel
Expand Down
10 changes: 6 additions & 4 deletions fuzztest/internal/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "absl/strings/str_replace.h"
#include "absl/strings/string_view.h"
#include "absl/strings/strip.h"
#include "absl/synchronization/notification.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
Expand Down Expand Up @@ -394,27 +395,28 @@ class Runtime::Watchdog {
}

~Watchdog() {
stop_requested_ = true;
stop_.Notify();
watchdog_thread_.join();
}

private:
void WatchdogLoop() {
watchdog_thread_started_ = true;
while (!stop_requested_) {
while (!stop_.HasBeenNotified()) {
runtime_.CheckWatchdogLimits();
runtime_.watchdog_spinlock_.Lock();
if (runtime_.watchdog_limit_exceeded_) {
runtime_.watchdog_spinlock_.Unlock();
break;
}
runtime_.watchdog_spinlock_.Unlock();
absl::SleepFor(absl::Seconds(1));
// Wake on teardown via Notify(); the timeout keeps limit checks periodic.
stop_.WaitForNotificationWithTimeout(absl::Seconds(1));
}
}

std::atomic<bool> watchdog_thread_started_ = false;
std::atomic<bool> stop_requested_ = false;
absl::Notification stop_;
std::thread watchdog_thread_;
Runtime& runtime_;
};
Expand Down
Loading