From 0aa2f67f883190a50d9a925f638e22a8b2f47b5b Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 5 Feb 2024 16:59:21 -0800 Subject: [PATCH] Check that all children have reachable present entries --- ConflictSet.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 72361eb..96d4f6b 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1173,11 +1173,28 @@ void checkParentPointers(Node *node, bool &success) { return expected; } +[[maybe_unused]] int64_t checkEntriesExist(Node *node, bool &success) { + int64_t total = node->entryPresent; + for (int i = getChildGeq(node, 0); i >= 0; i = getChildGeq(node, i + 1)) { + auto *child = getChildExists(node, i); + int64_t e = checkEntriesExist(child, success); + total += e; + if (e == 0) { + Arena arena; + fprintf(stderr, "%s has child %02x with no reachable entries\n", + printable(getSearchPath(arena, node)).c_str(), i); + success = false; + } + } + return total; +} + bool checkCorrectness(Node *node, ReferenceImpl &refImpl) { bool success = true; checkParentPointers(node, success); checkMaxVersion(node, success); + checkEntriesExist(node, success); std::string logicalMap; std::string referenceLogicalMap;