Make gArbitrary a local
This commit is contained in:
@@ -276,8 +276,6 @@ private:
|
|||||||
std::span<const uint8_t> bytecode;
|
std::span<const uint8_t> bytecode;
|
||||||
};
|
};
|
||||||
|
|
||||||
Arbitrary gArbitrary;
|
|
||||||
|
|
||||||
uint32_t Arbitrary::bounded(uint32_t s) {
|
uint32_t Arbitrary::bounded(uint32_t s) {
|
||||||
if (s == 1) {
|
if (s == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1414,27 +1412,27 @@ int main(void) {
|
|||||||
#ifdef ENABLE_FUZZ
|
#ifdef ENABLE_FUZZ
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
// TODO call setOldestVersion, and check range writes/reads
|
// TODO call setOldestVersion, and check range writes/reads
|
||||||
gArbitrary = Arbitrary{{data, size}};
|
Arbitrary arbitrary{{data, size}};
|
||||||
|
|
||||||
int64_t writeVersion = 0;
|
int64_t writeVersion = 0;
|
||||||
ConflictSet::Impl cs{writeVersion};
|
ConflictSet::Impl cs{writeVersion};
|
||||||
ReferenceImpl refImpl{writeVersion};
|
ReferenceImpl refImpl{writeVersion};
|
||||||
|
|
||||||
while (gArbitrary.hasEntropy()) {
|
while (arbitrary.hasEntropy()) {
|
||||||
Arena arena;
|
Arena arena;
|
||||||
{
|
{
|
||||||
int numWrites = gArbitrary.bounded(10);
|
int numWrites = arbitrary.bounded(10);
|
||||||
int64_t v = ++writeVersion;
|
int64_t v = ++writeVersion;
|
||||||
auto *writes = new (arena) ConflictSet::WriteRange[numWrites];
|
auto *writes = new (arena) ConflictSet::WriteRange[numWrites];
|
||||||
auto keys = set<std::string_view>(arena);
|
auto keys = set<std::string_view>(arena);
|
||||||
while (int(keys.size()) < numWrites) {
|
while (int(keys.size()) < numWrites) {
|
||||||
if (!gArbitrary.hasEntropy()) {
|
if (!arbitrary.hasEntropy()) {
|
||||||
// Tell the fuzzer it's not interesting
|
// Tell the fuzzer it's not interesting
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int keyLen = gArbitrary.bounded(8);
|
int keyLen = arbitrary.bounded(8);
|
||||||
auto *begin = new (arena) uint8_t[keyLen];
|
auto *begin = new (arena) uint8_t[keyLen];
|
||||||
gArbitrary.randomBytes(begin, keyLen);
|
arbitrary.randomBytes(begin, keyLen);
|
||||||
keys.insert(std::string_view((const char *)begin, keyLen));
|
keys.insert(std::string_view((const char *)begin, keyLen));
|
||||||
}
|
}
|
||||||
auto iter = keys.begin();
|
auto iter = keys.begin();
|
||||||
@@ -1458,18 +1456,18 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int numReads = gArbitrary.bounded(10);
|
int numReads = arbitrary.bounded(10);
|
||||||
int64_t v = writeVersion - gArbitrary.bounded(10);
|
int64_t v = writeVersion - arbitrary.bounded(10);
|
||||||
auto *reads = new (arena) ConflictSet::ReadRange[numReads];
|
auto *reads = new (arena) ConflictSet::ReadRange[numReads];
|
||||||
auto keys = set<std::string_view>(arena);
|
auto keys = set<std::string_view>(arena);
|
||||||
while (int(keys.size()) < numReads) {
|
while (int(keys.size()) < numReads) {
|
||||||
if (!gArbitrary.hasEntropy()) {
|
if (!arbitrary.hasEntropy()) {
|
||||||
// Tell the fuzzer it's not interesting
|
// Tell the fuzzer it's not interesting
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int keyLen = gArbitrary.bounded(8);
|
int keyLen = arbitrary.bounded(8);
|
||||||
auto *begin = new (arena) uint8_t[keyLen];
|
auto *begin = new (arena) uint8_t[keyLen];
|
||||||
gArbitrary.randomBytes(begin, keyLen);
|
arbitrary.randomBytes(begin, keyLen);
|
||||||
keys.insert(std::string_view((const char *)begin, keyLen));
|
keys.insert(std::string_view((const char *)begin, keyLen));
|
||||||
}
|
}
|
||||||
auto iter = keys.begin();
|
auto iter = keys.begin();
|
||||||
|
Reference in New Issue
Block a user