We need 8 hex chars for 4 byte keys
This commit is contained in:
@@ -37,6 +37,8 @@ target_compile_definitions(conflict_set_test PRIVATE ENABLE_TESTS)
|
|||||||
target_compile_options(conflict_set_test PRIVATE -UNDEBUG)
|
target_compile_options(conflict_set_test PRIVATE -UNDEBUG)
|
||||||
# Only emit compile warnings for test
|
# Only emit compile warnings for test
|
||||||
target_compile_options(conflict_set_test PRIVATE -Wall -Wextra -Wpedantic -Wunreachable-code)
|
target_compile_options(conflict_set_test PRIVATE -Wall -Wextra -Wpedantic -Wunreachable-code)
|
||||||
|
target_compile_options(conflict_set_test PRIVATE -fsanitize=address,undefined)
|
||||||
|
target_link_options(conflict_set_test PRIVATE -fsanitize=address,undefined)
|
||||||
add_test(NAME conflict_set_test COMMAND conflict_set_test)
|
add_test(NAME conflict_set_test COMMAND conflict_set_test)
|
||||||
|
|
||||||
# api smoke tests
|
# api smoke tests
|
||||||
|
@@ -502,7 +502,9 @@ Node *createNode(const Key &key, Node *parent, int64_t pointVersion,
|
|||||||
result->priority &= 0xff;
|
result->priority &= 0xff;
|
||||||
#endif
|
#endif
|
||||||
result->len = key.len;
|
result->len = key.len;
|
||||||
memcpy(result + 1, key.p, key.len);
|
if (key.len > 0) {
|
||||||
|
memcpy(result + 1, key.p, key.len);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,7 +740,7 @@ void lastLeqMulti(Arena &arena, Node *root, std::span<Key> keys,
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[maybe_unused]] Key toKey(Arena &arena, int n) {
|
[[maybe_unused]] Key toKey(Arena &arena, int n) {
|
||||||
constexpr int kMaxLength = 4;
|
constexpr int kMaxLength = 8;
|
||||||
int i = kMaxLength;
|
int i = kMaxLength;
|
||||||
uint8_t *itoaBuf = new (arena) uint8_t[kMaxLength];
|
uint8_t *itoaBuf = new (arena) uint8_t[kMaxLength];
|
||||||
memset(itoaBuf, '0', kMaxLength);
|
memset(itoaBuf, '0', kMaxLength);
|
||||||
@@ -750,7 +752,7 @@ void lastLeqMulti(Arena &arena, Node *root, std::span<Key> keys,
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[maybe_unused]] Key toKeyAfter(Arena &arena, int n) {
|
[[maybe_unused]] Key toKeyAfter(Arena &arena, int n) {
|
||||||
constexpr int kMaxLength = 4;
|
constexpr int kMaxLength = 8;
|
||||||
int i = kMaxLength;
|
int i = kMaxLength;
|
||||||
uint8_t *itoaBuf = new (arena) uint8_t[kMaxLength + 1];
|
uint8_t *itoaBuf = new (arena) uint8_t[kMaxLength + 1];
|
||||||
memset(itoaBuf, '0', kMaxLength);
|
memset(itoaBuf, '0', kMaxLength);
|
||||||
@@ -964,7 +966,8 @@ struct __attribute__((__visibility__("hidden"))) ConflictSet::Impl {
|
|||||||
// We could interleave the iteration in ::next, but we'd need a careful
|
// We could interleave the iteration in ::next, but we'd need a careful
|
||||||
// analysis for correctness and it's unlikely to be worthwhile.
|
// analysis for correctness and it's unlikely to be worthwhile.
|
||||||
auto *prev = ::next(newNode, false);
|
auto *prev = ::next(newNode, false);
|
||||||
// The empty key always exists. If *key is empty then we won't reach here.
|
// The empty key always exists. If key is empty then we won't reach
|
||||||
|
// here.
|
||||||
assert(prev != nullptr);
|
assert(prev != nullptr);
|
||||||
assert(prev->rangeVersion <= writeVersion);
|
assert(prev->rangeVersion <= writeVersion);
|
||||||
newNode->rangeVersion = prev->rangeVersion;
|
newNode->rangeVersion = prev->rangeVersion;
|
||||||
@@ -1251,21 +1254,22 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
int numWrites = gArbitrary.bounded(10);
|
int numWrites = gArbitrary.bounded(10);
|
||||||
int64_t v = ++writeVersion;
|
int64_t v = ++writeVersion;
|
||||||
auto *writes = new (arena) ConflictSet::WriteRange[numWrites];
|
auto *writes = new (arena) ConflictSet::WriteRange[numWrites];
|
||||||
std::set<std::string_view, std::less<std::string_view>, ArenaAlloc<std::string_view>> keys{
|
std::set<std::string_view, std::less<std::string_view>,
|
||||||
ArenaAlloc<int>(&arena)};
|
ArenaAlloc<std::string_view>>
|
||||||
|
keys{ArenaAlloc<int>(&arena)};
|
||||||
while (int(keys.size()) < numWrites) {
|
while (int(keys.size()) < numWrites) {
|
||||||
if (!gArbitrary.hasEntropy()) {
|
if (!gArbitrary.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 = gArbitrary.bounded(8);
|
||||||
auto* begin = new (arena) uint8_t[keyLen];
|
auto *begin = new (arena) uint8_t[keyLen];
|
||||||
gArbitrary.randomHex(begin, keyLen);
|
gArbitrary.randomHex(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();
|
||||||
for (int i = 0; i < numWrites; ++i) {
|
for (int i = 0; i < numWrites; ++i) {
|
||||||
writes[i].begin.p = (const uint8_t*)iter->data();
|
writes[i].begin.p = (const uint8_t *)iter->data();
|
||||||
writes[i].begin.len = iter->size();
|
writes[i].begin.len = iter->size();
|
||||||
writes[i].end.len = 0;
|
writes[i].end.len = 0;
|
||||||
writes[i].writeVersion = v;
|
writes[i].writeVersion = v;
|
||||||
@@ -1281,21 +1285,22 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
int numReads = gArbitrary.bounded(10);
|
int numReads = gArbitrary.bounded(10);
|
||||||
int64_t v = writeVersion - gArbitrary.bounded(10);
|
int64_t v = writeVersion - gArbitrary.bounded(10);
|
||||||
auto *reads = new (arena) ConflictSet::ReadRange[numReads];
|
auto *reads = new (arena) ConflictSet::ReadRange[numReads];
|
||||||
std::set<std::string_view, std::less<std::string_view>, ArenaAlloc<std::string_view>> keys{
|
std::set<std::string_view, std::less<std::string_view>,
|
||||||
ArenaAlloc<int>(&arena)};
|
ArenaAlloc<std::string_view>>
|
||||||
|
keys{ArenaAlloc<int>(&arena)};
|
||||||
while (int(keys.size()) < numReads) {
|
while (int(keys.size()) < numReads) {
|
||||||
if (!gArbitrary.hasEntropy()) {
|
if (!gArbitrary.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 = gArbitrary.bounded(8);
|
||||||
auto* begin = new (arena) uint8_t[keyLen];
|
auto *begin = new (arena) uint8_t[keyLen];
|
||||||
gArbitrary.randomHex(begin, keyLen);
|
gArbitrary.randomHex(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();
|
||||||
for (int i = 0; i < numReads; ++i) {
|
for (int i = 0; i < numReads; ++i) {
|
||||||
reads[i].begin.p = (const uint8_t*)iter->data();
|
reads[i].begin.p = (const uint8_t *)iter->data();
|
||||||
reads[i].begin.len = iter->size();
|
reads[i].begin.len = iter->size();
|
||||||
reads[i].end.len = 0;
|
reads[i].end.len = 0;
|
||||||
reads[i].readVersion = v;
|
reads[i].readVersion = v;
|
||||||
|
Reference in New Issue
Block a user