Skip to content
Merged
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
4 changes: 2 additions & 2 deletions centipede/centipede.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void Centipede::LoadShard(const Environment &load_env, size_t shard_index,
const std::string features_path = wd.FeaturesFilePaths().Shard(shard_index);
if (env_.serialize_shard_loads) {
ABSL_CONST_INIT static absl::Mutex load_shard_mu{absl::kConstInit};
absl::MutexLock lock(&load_shard_mu);
absl::MutexLock lock(load_shard_mu);
ReadShard(corpus_path, features_path, input_features_callback);
} else {
ReadShard(corpus_path, features_path, input_features_callback);
Expand Down Expand Up @@ -914,7 +914,7 @@ void Centipede::ReportCrash(std::string_view binary,
const size_t suspect_input_idx = std::clamp<size_t>(
batch_result.num_outputs_read(), 0, input_vec.size() - 1);
auto log_execution_failure = [&](std::string_view log_prefix) {
absl::MutexLock lock(&GetExecutionLoggingMutex());
absl::MutexLock lock(GetExecutionLoggingMutex());
FUZZTEST_LOG(INFO)
<< log_prefix << "Batch execution failed:"
<< "\nBinary : " << binary
Expand Down
2 changes: 1 addition & 1 deletion centipede/centipede_callbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ void CentipedeCallbacks::PrintExecutionLog() const {
}
std::string log_text;
ReadFromLocalFile(execute_log_path_, log_text);
absl::MutexLock lock(&GetExecutionLoggingMutex());
absl::MutexLock lock(GetExecutionLoggingMutex());
for (const auto& log_line :
absl::StrSplit(absl::StripAsciiWhitespace(log_text), '\n')) {
FUZZTEST_LOG(INFO).NoPrefix() << "LOG: " << log_line;
Expand Down
2 changes: 1 addition & 1 deletion centipede/command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ std::string Command::ReadRedirectedStderr() const {
}

void Command::LogProblemInfo(std::string_view message) const {
absl::MutexLock lock(&GetExecutionLoggingMutex());
absl::MutexLock lock(GetExecutionLoggingMutex());

FUZZTEST_LOG(ERROR) << message;
FUZZTEST_LOG(ERROR).NoPrefix() << "=== COMMAND ===";
Expand Down
2 changes: 1 addition & 1 deletion centipede/coverage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void Coverage::DumpReportToFile(const SymbolTable &symbols,

std::string CoverageLogger::ObserveAndDescribeIfNew(PCIndex pc_index) {
if (pc_table_.empty()) return ""; // Fast-path return (symbolization is off).
absl::MutexLock l(&mu_);
absl::MutexLock l(mu_);
if (!observed_indices_.insert(pc_index).second) return "";
std::ostringstream os;
if (pc_index >= pc_table_.size()) {
Expand Down
10 changes: 5 additions & 5 deletions centipede/distill.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ class CorpusShardWriter {
virtual ~CorpusShardWriter() = default;

void WriteElt(CorpusElt elt) {
absl::MutexLock lock(&mu_);
absl::MutexLock lock(mu_);
WriteEltImpl(std::move(elt));
}

void WriteBatch(CorpusEltVec elts) {
absl::MutexLock lock(&mu_);
absl::MutexLock lock(mu_);
FUZZTEST_VLOG(1) << log_prefix_ << "writing " << elts.size()
<< " elements to output shard:\n"
<< VV(corpus_path_) << "\n"
Expand All @@ -195,7 +195,7 @@ class CorpusShardWriter {
}

Stats GetStats() const {
absl::MutexLock lock(&mu_);
absl::MutexLock lock(mu_);
return stats_;
}

Expand Down Expand Up @@ -268,7 +268,7 @@ class DistillingInputFilter {
} {}

std::optional<CorpusElt> FilterElt(CorpusElt elt) {
absl::MutexLock lock{&mu_};
absl::MutexLock lock{mu_};

++stats_.num_total_elts;

Expand All @@ -289,7 +289,7 @@ class DistillingInputFilter {
}

Stats GetStats() {
absl::MutexLock lock{&mu_};
absl::MutexLock lock{mu_};
std::stringstream ss;
ss << seen_features_;
stats_.coverage_str = std::move(ss).str();
Expand Down
6 changes: 3 additions & 3 deletions centipede/minimize_crash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct MinimizerWorkQueue {

// Returns up to `max_num_crashers` most recently added crashers.
std::vector<ByteArray> GetRecentCrashers(size_t max_num_crashers) {
absl::MutexLock lock(&mutex_);
absl::MutexLock lock(mutex_);
size_t num_crashers_to_return =
std::min(crashers_.size(), max_num_crashers);
return {crashers_.end() - num_crashers_to_return, crashers_.end()};
Expand All @@ -62,7 +62,7 @@ struct MinimizerWorkQueue {
// Adds `crasher` to the queue, writes it to `crash_dir_path_/Hash(crasher)`.
// The crasher must be smaller than the original one.
void AddCrasher(ByteArray crasher) {
absl::MutexLock lock(&mutex_);
absl::MutexLock lock(mutex_);
FUZZTEST_CHECK_LT(crasher.size(), crashers_.front().size());
crashers_.emplace_back(crasher);
// Write the crasher to disk.
Expand All @@ -74,7 +74,7 @@ struct MinimizerWorkQueue {

// Returns true if new smaller crashes were found.
bool SmallerCrashesFound() const {
absl::MutexLock lock(&mutex_);
absl::MutexLock lock(mutex_);
return crashers_.size() > 1;
}

Expand Down
10 changes: 5 additions & 5 deletions centipede/periodic_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class PeriodicAction::Impl {
}

void StopAsync() {
absl::MutexLock lock{&mu_};
absl::MutexLock lock{mu_};
stop_ = true;
}

void Nudge() {
absl::MutexLock lock{&mu_};
absl::MutexLock lock{mu_};
nudge_ = true;
}

Expand All @@ -62,7 +62,7 @@ class PeriodicAction::Impl {
const bool schedule = !nudge_ && !stop_;
const bool nudge = nudge_;
const bool stop = stop_;
mu_.Unlock();
mu_.unlock();
// NOTE: The caller might call `Stop()` immediately after one final
// `Nudge()`: in that case we still should run the action, and only then
// terminate the loop. This is in contrast to waking after sleeping the
Expand All @@ -80,12 +80,12 @@ class PeriodicAction::Impl {

void SleepOrWakeEarly(absl::Duration duration)
ABSL_EXCLUSIVE_LOCK_FUNCTION(mu_) {
mu_.Lock();
mu_.lock();
// NOTE: Reset only `nudge_`, but not `stop_`: nudging is transient and
// can be activated repeatedly, the latter is persistent and can be
// activated only once (repeated calls to `Stop()` are no-ops).
nudge_ = false;
mu_.Unlock();
mu_.unlock();
const auto wake_early = [this]() {
mu_.AssertReaderHeld();
return nudge_ || stop_;
Expand Down
14 changes: 7 additions & 7 deletions centipede/periodic_action_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,20 @@ TEST(PeriodicActionTest, NudgeThenStopStillRunsAction) {
absl::Mutex count_mu;
PeriodicAction action{
[&count, &count_mu]() {
absl::MutexLock lock{&count_mu};
absl::MutexLock lock{count_mu};
++count;
},
PeriodicAction::ZeroDelayConstInterval(absl::InfiniteDuration()),
};
absl::SleepFor(absl::Seconds(1));
{
absl::MutexLock lock{&count_mu};
absl::MutexLock lock{count_mu};
EXPECT_EQ(count, 1);
}
action.Nudge();
action.Stop();
{
absl::MutexLock lock{&count_mu};
absl::MutexLock lock{count_mu};
EXPECT_EQ(count, 2);
}
}
Expand All @@ -170,21 +170,21 @@ TEST(PeriodicActionTest, NudgeThenDtorStillRunsAction) {
{
PeriodicAction action{
[&count, &count_mu]() {
absl::MutexLock lock{&count_mu};
absl::MutexLock lock{count_mu};
++count;
},
PeriodicAction::ZeroDelayConstInterval(absl::InfiniteDuration()),
};
absl::SleepFor(absl::Seconds(1));
{
absl::MutexLock lock{&count_mu};
absl::MutexLock lock{count_mu};
EXPECT_EQ(count, 1);
}
EXPECT_EQ(count, 1);
action.Nudge();
}
{
absl::MutexLock lock{&count_mu};
absl::MutexLock lock{count_mu};
EXPECT_EQ(count, 2);
}
}
Expand All @@ -198,7 +198,7 @@ TEST(PeriodicActionTest, ActionIsMoveable) {
{
PeriodicAction moved_from{
[&mu, &thread_ids]() {
absl::WriterMutexLock lock{&mu};
absl::WriterMutexLock lock{mu};
thread_ids.push_back(std::this_thread::get_id());
},
PeriodicAction::ZeroDelayConstInterval(absl::Milliseconds(10)),
Expand Down
8 changes: 4 additions & 4 deletions centipede/resource_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ template <typename ResourceT>
typename ResourcePool<ResourceT>::LeaseToken
ResourcePool<ResourceT>::AcquireLeaseBlocking(LeaseRequest&& request) {
if (FUZZTEST_VLOG_IS_ON(1)) {
absl::ReaderMutexLock lock{&pool_mu_};
absl::ReaderMutexLock lock{pool_mu_};
FUZZTEST_VLOG(1) << "Received lease request " << request.id //
<< "\nrequested: " << request.amount.FormattedStr() //
<< "\nquota: " << quota_.FormattedStr() //
Expand Down Expand Up @@ -144,22 +144,22 @@ ResourcePool<ResourceT>::AcquireLeaseBlocking(LeaseRequest&& request) {
<< "\nleased : " << (-request.amount).FormattedStr() //
<< "\nafter : " << (pool_ - request.amount).FormattedStr();
pool_ = pool_ - request.amount;
pool_mu_.Unlock();
pool_mu_.unlock();
return LeaseToken{*this, std::move(request)};
} else {
absl::Status error = //
absl::DeadlineExceededError(absl::StrCat( //
"Lease request ", request.id, " timed out; timeout: ",
request.timeout, " requested: [", request.amount.ShortStr(),
"] current pool: [", pool_.ShortStr(), "]"));
pool_mu_.Unlock();
pool_mu_.unlock();
return LeaseToken{*this, std::move(request), std::move(error)};
}
}

template <typename ResourceT>
void ResourcePool<ResourceT>::ReturnLease(const LeaseToken& lease) {
absl::WriterMutexLock lock{&pool_mu_};
absl::WriterMutexLock lock{pool_mu_};
FUZZTEST_VLOG(1) //
<< "Returning lease " << lease.request().id //
<< "\nreq age : " << lease.request().age() //
Expand Down
10 changes: 5 additions & 5 deletions centipede/rusage_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const RUsageProfiler::Snapshot& RUsageProfiler::TakeSnapshot( //
return kEmpty;
}

absl::WriterMutexLock lock{&mutex_};
absl::WriterMutexLock lock{mutex_};

RUsageTiming snap_timing = RUsageTiming::Zero();
RUsageTiming delta_timing = RUsageTiming::Zero();
Expand Down Expand Up @@ -420,7 +420,7 @@ void RUsageProfiler::StartTimelapse( //
absl::Duration interval, //
bool also_log, //
std::string title) {
absl::WriterMutexLock lock{&mutex_};
absl::WriterMutexLock lock{mutex_};
FUZZTEST_CHECK(!timelapse_recorder_) << "StopTimelapse() wasn't called";
timelapse_recorder_ = std::make_unique<PeriodicAction>(
[this, loc = std::move(loc), title = std::move(title), also_log]() {
Expand All @@ -431,7 +431,7 @@ void RUsageProfiler::StartTimelapse( //
}

void RUsageProfiler::StopTimelapse() {
absl::WriterMutexLock lock{&mutex_};
absl::WriterMutexLock lock{mutex_};
FUZZTEST_CHECK(timelapse_recorder_) << "StartTimelapse() wasn't called";
timelapse_recorder_.reset();
}
Expand Down Expand Up @@ -483,10 +483,10 @@ void RUsageProfiler::PrintReport( //

void RUsageProfiler::GenerateReport(
ReportSink* absl_nonnull report_sink) const {
absl::ReaderMutexLock lock{&mutex_};
absl::ReaderMutexLock lock{mutex_};
// Prevent interleaved reports from multiple concurrent RUsageProfilers.
ABSL_CONST_INIT static absl::Mutex report_generation_mutex_{absl::kConstInit};
absl::WriterMutexLock logging_lock{&report_generation_mutex_};
absl::WriterMutexLock logging_lock{report_generation_mutex_};

ProfileReportGenerator gen{snapshots_, report_sink};

Expand Down
2 changes: 1 addition & 1 deletion centipede/rusage_stats_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class CpuHog {
}
// Let one of the hogs notify the caller that the hogging is over.
{
absl::MutexLock lock{&mu_};
absl::MutexLock lock{mu_};
if (!hogging_stopped->HasBeenNotified()) {
hogging_stopped->Notify();
}
Expand Down
4 changes: 2 additions & 2 deletions centipede/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static std::vector<std::string> *dirs_to_delete_at_exit
// Atexit handler added by CreateLocalDirRemovedAtExit().
// Deletes all dirs in dirs_to_delete_at_exit.
static void RemoveDirsAtExit() {
absl::MutexLock lock(&dirs_to_delete_at_exit_mutex);
absl::MutexLock lock(dirs_to_delete_at_exit_mutex);
for (auto &dir : *dirs_to_delete_at_exit) {
std::error_code error;
std::filesystem::remove_all(dir, error);
Expand All @@ -195,7 +195,7 @@ void CreateLocalDirRemovedAtExit(std::string_view path) {
<< "Unable to clean up existing dir " << path << ": " << error.message();
std::filesystem::create_directories(path);
// Add to dirs_to_delete_at_exit.
absl::MutexLock lock(&dirs_to_delete_at_exit_mutex);
absl::MutexLock lock(dirs_to_delete_at_exit_mutex);
if (!dirs_to_delete_at_exit) {
dirs_to_delete_at_exit = new std::vector<std::string>();
atexit(&RemoveDirsAtExit);
Expand Down
Loading