No public description
PiperOrigin-RevId: 795496469
diff --git a/domain_tests/BUILD b/domain_tests/BUILD
index 0f1548a..add0923 100644
--- a/domain_tests/BUILD
+++ b/domain_tests/BUILD
@@ -61,6 +61,7 @@
tags = ["cpu:4"],
deps = [
":domain_testing",
+ "//mustang:generic_servlet_cc_proto",
"@abseil-cpp//absl/container:flat_hash_set",
"@abseil-cpp//absl/random",
"@abseil-cpp//absl/random:bit_gen_ref",
diff --git a/domain_tests/arbitrary_domains_protobuf_test.cc b/domain_tests/arbitrary_domains_protobuf_test.cc
index 3028ac8..1010438 100644
--- a/domain_tests/arbitrary_domains_protobuf_test.cc
+++ b/domain_tests/arbitrary_domains_protobuf_test.cc
@@ -24,6 +24,7 @@
#include <utility>
#include <vector>
+#include "mustang/generic-servlet.pb.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/container/flat_hash_set.h"
@@ -782,5 +783,31 @@
std::cout << "ratio: " << multi_thread_time / single_thread_time << "\n";
}
+TEST(ProtocolBuffer, MutationInParallelIsSafeWithAGlobalDomain) {
+ const unsigned int num_threads =
+ std::max(1u, std::thread::hardware_concurrency() / 2);
+ auto domain = Arbitrary<GenericSearchRequest>();
+
+ // Make the mutation runs comparable by using the same seed sequence.
+ absl::SeedSeq seed_seq = absl::MakeSeedSeq();
+ auto thread_task = [&]() {
+ absl::BitGen bitgen{seed_seq};
+ // Init and Mutate on the SHARED domain instance
+ // These calls will concurrently access the same underlying
+ // ProtoPolicy::RecursiveFieldsCaches
+ auto corpus_value = domain.Init(bitgen);
+ for (int j = 0; j < 500; ++j) {
+ domain.Mutate(corpus_value, bitgen, {}, false);
+ }
+ };
+
+ std::vector<std::thread> workers;
+ workers.reserve(num_threads);
+ for (int i = 0; i < num_threads; ++i) {
+ workers.emplace_back(thread_task);
+ }
+ for (auto& worker : workers) worker.join();
+}
+
} // namespace
} // namespace fuzztest