Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No public description #920

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
29 changes: 25 additions & 4 deletions centipede/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cc_binary(
":centipede_interface",
":config_file",
":environment_flags",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/log:flags",
],
)
Expand All @@ -76,6 +77,7 @@ cc_binary(
":seed_corpus_maker_flags",
":seed_corpus_maker_lib",
":util",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
Expand All @@ -92,6 +94,7 @@ cc_binary(
":logging",
":remote_file",
":rusage_profiler",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
Expand Down Expand Up @@ -248,6 +251,7 @@ cc_library(
":logging",
":remote_file",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
Expand Down Expand Up @@ -295,6 +299,7 @@ cc_library(
":logging",
":remote_file",
":util",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/flags:reflection",
Expand All @@ -321,6 +326,7 @@ cc_library(
hdrs = ["rusage_stats.h"],
visibility = ["//visibility:public"],
deps = [
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
Expand All @@ -336,6 +342,7 @@ cc_library(
deps = [
":rusage_stats",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
Expand Down Expand Up @@ -443,6 +450,7 @@ cc_library(
hdrs = ["shared_memory_blob_sequence.h"],
linkopts = ["-lrt"], # for shm_open.
visibility = PUBLIC_API_VISIBILITY,
deps = ["@com_google_absl//absl/base:nullability"],
# don't add any dependencies.
)

Expand Down Expand Up @@ -509,6 +517,7 @@ cc_library(
":execution_metadata",
":knobs",
":mutation_input",
"@com_google_absl//absl/base:nullability",
],
)

Expand Down Expand Up @@ -594,6 +603,7 @@ cc_library(
":defs",
":logging",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
] + select({
Expand Down Expand Up @@ -708,6 +718,7 @@ cc_library(
":shared_memory_blob_sequence",
":util",
":workdir",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
Expand Down Expand Up @@ -796,6 +807,7 @@ cc_library(
":util",
":workdir",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
Expand Down Expand Up @@ -940,6 +952,7 @@ cc_library(
name = "runner_fork_server",
srcs = ["runner_fork_server.cc"],
visibility = PUBLIC_API_VISIBILITY,
deps = ["@com_google_absl//absl/base:nullability"],
alwayslink = 1, # Otherwise the linker drops the fork server.
)

Expand Down Expand Up @@ -1045,7 +1058,7 @@ cc_library(
linkopts = RUNNER_LINKOPTS,
linkstatic = True, # Must be linked statically even when dynamic_mode=on.
visibility = ["//visibility:public"],
deps = RUNNER_DEPS,
deps = RUNNER_DEPS + ["@com_google_absl//absl/base:nullability"],
)

# Same as :centipede_runner_no_main but as a DSO. Experimental.
Expand All @@ -1056,7 +1069,7 @@ cc_binary(
linkopts = RUNNER_LINKOPTS,
linkshared = 1,
visibility = ["//visibility:public"],
deps = RUNNER_DEPS,
deps = RUNNER_DEPS + ["@com_google_absl//absl/base:nullability"],
)

# A full self-contained library archive that external clients should link to
Expand All @@ -1069,7 +1082,7 @@ cc_library(
linkopts = RUNNER_LINKOPTS,
linkstatic = True, # Must be linked statically even when dynamic_mode=on.
visibility = ["//visibility:public"],
deps = RUNNER_DEPS,
deps = RUNNER_DEPS + ["@com_google_absl//absl/base:nullability"],
)

# Utilities for seed corpus generation.
Expand Down Expand Up @@ -1274,6 +1287,7 @@ cc_test(
deps = [
":logging",
":rusage_stats",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/synchronization",
Expand Down Expand Up @@ -1347,6 +1361,7 @@ cc_test(
":test_util",
":util",
":workdir",
"@com_google_absl//absl/base:nullability",
"@com_google_googletest//:gtest_main",
],
)
Expand Down Expand Up @@ -1496,6 +1511,7 @@ cc_test(
deps = [
":callstack",
":defs",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_googletest//:gtest_main",
],
Expand Down Expand Up @@ -1530,7 +1546,10 @@ cc_test(
cc_binary(
name = "command_test_helper",
srcs = ["command_test_helper.cc"],
deps = [":runner_fork_server"],
deps = [
":runner_fork_server",
"@com_google_absl//absl/base:nullability",
],
)

cc_test(
Expand All @@ -1554,6 +1573,7 @@ cc_test(
srcs = ["runner_cmp_trace_test.cc"],
deps = [
":runner_cmp_trace",
"@com_google_absl//absl/base:nullability",
"@com_google_googletest//:gtest_main",
],
)
Expand Down Expand Up @@ -1651,6 +1671,7 @@ cc_test(
":test_util",
":util",
":workdir",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
Expand Down
1 change: 1 addition & 0 deletions centipede/batch_fuzz_example/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ cc_binary(
srcs = ["customized_centipede_main.cc"],
deps = [
":customized_centipede_lib",
"@com_google_absl//absl/base:nullability",
"@com_google_fuzztest//centipede:centipede_callbacks",
"@com_google_fuzztest//centipede:centipede_interface",
"@com_google_fuzztest//centipede:config_file",
Expand Down
3 changes: 2 additions & 1 deletion centipede/batch_fuzz_example/customized_centipede_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/base/nullability.h"
#include "./centipede/batch_fuzz_example/customized_centipede.h"
#include "./centipede/centipede_callbacks.h"
#include "./centipede/centipede_interface.h"
#include "./centipede/config_file.h"
#include "./centipede/environment_flags.h"

int main(int argc, char** argv) {
int main(int argc, absl::Nonnull<char**> argv) {
const auto leftover_argv = centipede::config::InitCentipede(argc, argv);

// Reads flags; must happen after ParseCommandLine().
Expand Down
3 changes: 2 additions & 1 deletion centipede/blob_file_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <filesystem> // NOLINT
#include <string>

#include "absl/base/nullability.h"
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
Expand Down Expand Up @@ -133,7 +134,7 @@ void Convert( //
} // namespace
} // namespace centipede

int main(int argc, char** argv) {
int main(int argc, absl::Nonnull<char**> argv) {
(void)centipede::config::InitRuntime(argc, argv);

const std::string in = absl::GetFlag(FLAGS_in);
Expand Down
3 changes: 2 additions & 1 deletion centipede/byte_array_mutator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <utility>
#include <vector>

#include "absl/base/nullability.h"
#include "./centipede/defs.h"
#include "./centipede/execution_metadata.h"
#include "./centipede/knobs.h"
Expand All @@ -40,7 +41,7 @@ class DictEntry {
if (size_ > kMaxEntrySize) __builtin_trap();
memcpy(bytes_, bytes.data(), bytes.size());
}
const uint8_t *begin() const { return bytes_; }
absl::Nonnull<const uint8_t *> begin() const { return bytes_; }
const uint8_t *end() const { return bytes_ + size_; }
size_t size() const { return size_; }
bool operator<(const DictEntry &other) const {
Expand Down
3 changes: 2 additions & 1 deletion centipede/callstack_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/nullability.h"
#include "absl/container/flat_hash_set.h"
#include "./centipede/defs.h"

Expand Down Expand Up @@ -76,7 +77,7 @@ static void RecordCallStack() {
PC, reinterpret_cast<uintptr_t>(__builtin_frame_address(0)))

// Don't let the compiler be too smart.
static inline void BreakOptimization(const void *arg) {
static inline void BreakOptimization(absl::Nullable<const void *> arg) {
__asm__ __volatile__("" : : "r"(arg) : "memory");
}

Expand Down
10 changes: 6 additions & 4 deletions centipede/centipede.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

#include "absl/base/attributes.h"
#include "absl/base/const_init.h" // NOLINT
#include "absl/base/nullability.h"
#include "absl/container/flat_hash_set.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
Expand Down Expand Up @@ -342,10 +343,11 @@ size_t Centipede::AddPcPairFeatures(FeatureVec &fv) {
return num_added_pairs;
}

bool Centipede::RunBatch(const std::vector<ByteArray> &input_vec,
BlobFileWriter *corpus_file,
BlobFileWriter *features_file,
BlobFileWriter *unconditional_features_file) {
bool Centipede::RunBatch(
const std::vector<ByteArray> &input_vec,
absl::Nullable<BlobFileWriter *> corpus_file,
absl::Nullable<BlobFileWriter *> features_file,
absl::Nullable<BlobFileWriter *> unconditional_features_file) {
BatchResult batch_result;
bool success = ExecuteAndReportCrash(env_.binary, input_vec, batch_result);
CHECK_EQ(input_vec.size(), batch_result.results().size());
Expand Down
8 changes: 5 additions & 3 deletions centipede/centipede.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "./centipede/binary_info.h"
// Copyright 2022 The Centipede Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,7 +20,9 @@
#include <string_view>
#include <vector>

#include "absl/base/nullability.h"
#include "absl/time/time.h"
#include "./centipede/binary_info.h"
#include "./centipede/blob_file.h"
#include "./centipede/centipede_callbacks.h"
#include "./centipede/command.h"
Expand Down Expand Up @@ -77,8 +78,9 @@ class Centipede {
// Returns true if new features were observed.
// Post-condition: `batch_result.results.size()` == `input_vec.size()`.
bool RunBatch(const std::vector<ByteArray> &input_vec,
BlobFileWriter *corpus_file, BlobFileWriter *features_file,
BlobFileWriter *unconditional_features_file);
absl::Nullable<BlobFileWriter *> corpus_file,
absl::Nullable<BlobFileWriter *> features_file,
absl::Nullable<BlobFileWriter *> unconditional_features_file);
// Loads seed inputs from the user callbacks.
void LoadSeedInputs();
// Loads a shard `shard_index` from `load_env.workdir`.
Expand Down
3 changes: 2 additions & 1 deletion centipede/centipede_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string_view>
#include <vector>

#include "absl/base/nullability.h"
#include "absl/log/check.h"
#include "./centipede/binary_info.h"
#include "./centipede/byte_array_mutator.h"
Expand Down Expand Up @@ -198,7 +199,7 @@ class ScopedCentipedeCallbacks {
const Environment &env)
: factory_(factory), callbacks_(factory_.create(env)) {}
~ScopedCentipedeCallbacks() { factory_.destroy(callbacks_); }
CentipedeCallbacks *callbacks() { return callbacks_; }
absl::Nonnull<CentipedeCallbacks *> callbacks() { return callbacks_; }

private:
CentipedeCallbacksFactory &factory_;
Expand Down
3 changes: 2 additions & 1 deletion centipede/centipede_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/base/nullability.h"
#include "./centipede/centipede_callbacks.h"
#include "./centipede/centipede_default_callbacks.h"
#include "./centipede/centipede_interface.h"
#include "./centipede/config_file.h"
#include "./centipede/environment_flags.h"

int main(int argc, char** argv) {
int main(int argc, absl::Nonnull<char**> argv) {
const auto leftover_argv = centipede::config::InitCentipede(argc, argv);

const auto env = centipede::CreateEnvironmentFromFlags(leftover_argv);
Expand Down
5 changes: 4 additions & 1 deletion centipede/centipede_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/nullability.h"
#include "absl/container/flat_hash_set.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
Expand Down Expand Up @@ -124,7 +125,9 @@ class CentipedeMock : public CentipedeCallbacks {
class MockFactory : public CentipedeCallbacksFactory {
public:
explicit MockFactory(CentipedeCallbacks &cb) : cb_(cb) {}
CentipedeCallbacks *create(const Environment &env) override { return &cb_; }
absl::Nonnull<CentipedeCallbacks *> create(const Environment &env) override {
return &cb_;
}
void destroy(CentipedeCallbacks *cb) override { EXPECT_EQ(cb, &cb_); }

private:
Expand Down
4 changes: 3 additions & 1 deletion centipede/command_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
#include <cstdlib>
#include <cstring>

#include "absl/base/nullability.h"

// A binary linked with the fork server that exits/crashes in different ways.
int main(int argc, char **argv) {
int main(int argc, absl::Nonnull<char **> argv) {
assert(argc == 2);
printf("Got input: %s", argv[1]);
fflush(stdout);
Expand Down
3 changes: 2 additions & 1 deletion centipede/config_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <utility>
#include <vector>

#include "absl/base/nullability.h"
#include "absl/flags/declare.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
Expand Down Expand Up @@ -230,7 +231,7 @@ set -x
return path;
}

std::vector<std::string> InitCentipede(int argc, char** argv) {
std::vector<std::string> InitCentipede(int argc, absl::Nonnull<char**> argv) {
std::vector<std::string> leftover_argv;

// main_runtime_init() is allowed to remove recognized flags from `argv`, so
Expand Down
Loading