Enable asserts in fuzz target

This commit is contained in:
2024-05-29 22:00:18 -07:00
parent 10b032076e
commit 16c2bb1d11
3 changed files with 22 additions and 29 deletions

View File

@@ -62,7 +62,9 @@ set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
add_subdirectory(third_party)
add_executable(versioned_map_main VersionedMap.cpp RootSet.cpp)
set(SOURCES VersionedMap.cpp RootSet.cpp)
add_executable(versioned_map_main ${SOURCES})
target_include_directories(versioned_map_main
PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(versioned_map_main PRIVATE nanobench)
@@ -73,7 +75,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_options(versioned_map_main PRIVATE -fsanitize=address,undefined)
endif()
add_library(${PROJECT_NAME}-object OBJECT VersionedMap.cpp RootSet.cpp)
add_library(${PROJECT_NAME}-object OBJECT ${SOURCES})
target_compile_options(${PROJECT_NAME}-object PRIVATE -fno-exceptions -fno-rtti)
target_include_directories(${PROJECT_NAME}-object
@@ -155,11 +157,11 @@ if(BUILD_TESTING)
cmake_pop_check_state()
if(HAS_LIB_FUZZER)
add_executable(facade_fuzz FacadeFuzz.cpp)
target_link_libraries(facade_fuzz PRIVATE ${PROJECT_NAME})
add_executable(facade_fuzz FacadeFuzz.cpp ${SOURCES})
target_include_directories(facade_fuzz
PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_compile_options(facade_fuzz PRIVATE ${FUZZ_FLAGS} ${TEST_FLAGS})
target_link_options(facade_fuzz PRIVATE ${FUZZ_FLAGS} -fsanitize=fuzzer)
endif()
endif()

View File

@@ -392,7 +392,7 @@ inline Random seededRandom() {
return Random{seed[0], seed[1]};
}
inline thread_local Random gRandom = seededRandom();
static thread_local Random gRandom = seededRandom();
// ==================== END RANDOM IMPL ====================

View File

@@ -275,14 +275,14 @@ struct MemManager {
// in the stack, so we need 2 * kPathLengthUpperBound
uint32_t stack[2 * kPathLengthUpperBound];
int stackIndex = 0;
auto tryPush = [&](uint32_t parent, uint32_t child) {
auto tryPush = [&]([[maybe_unused]] uint32_t parent, uint32_t child) {
if (!reachable.set(child)) {
#if DEBUG_VERBOSE
if (debugVerboseEnabled) {
printf(" GC: reach: %u (parent %u)\n", child, parent);
}
#endif
assert(stackIndex < sizeof(stack) / sizeof(stack[0]));
assert(stackIndex < int(sizeof(stack) / sizeof(stack[0])));
stack[stackIndex++] = child;
}
};
@@ -344,7 +344,7 @@ struct MemManager {
// Entries to the right of max don't need to be in the freelist. They're
// allocated by pointer bumping.
for (int i = max + 1; i < next; ++i) {
for (uint32_t i = max + 1; i < next; ++i) {
if (base[i].entry != nullptr) {
#if DEBUG_VERBOSE
if (debugVerboseEnabled) {
@@ -779,7 +779,7 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
const bool direction = finger.backDirection();
finger.pop();
auto &parent = finger.backNodeRef();
auto old = parent;
[[maybe_unused]] auto old = parent;
parent = update(parent, direction, node, latestVersion);
node = parent;
}
@@ -1272,31 +1272,22 @@ void VersionedMap::Impl::firstGeq(const weaselab::VersionedMap::Key *key,
const Entry *prev = nullptr;
for (;;) {
if (finger.searchPathSize() > 0) {
materializeMutations(iterator[i].impl, prev, nullptr);
if (iterator[i].impl->mutationCount > 0) {
break;
}
} else {
if (finger.searchPathSize() == 0) {
break;
} else {
materializeMutations(iterator[i].impl, prev, nullptr);
for (int j = 0; j < iterator[i].impl->mutationCount; ++j) {
if (geq(iterator[i].impl->mutations[j], key[i])) {
iterator[i].impl->mutationIndex = j;
goto loopEnd;
}
}
}
prev = iterator[i].impl->map->mm.base[finger.backNode()].entry;
iterator[i].impl->map->move<std::memory_order_acquire, true>(
finger, iterator[i].impl->version);
}
if (iterator[i].impl->mutationCount == 0) {
assert(finger.searchPathSize() == 0);
} else {
[[maybe_unused]] bool match = false;
for (int j = 0; j < iterator[i].impl->mutationCount; ++j) {
if (geq(iterator[i].impl->mutations[j], key[i])) {
iterator[i].impl->mutationIndex = j;
match = true;
break;
}
}
assert(match);
}
loopEnd:;
}
}