From c45d3cba8173f6ae1edb1104753a1ded928fef5a Mon Sep 17 00:00:00 2001 From: Weaselbot Date: Mon, 26 Oct 2026 19:19:43 -0400 Subject: [PATCH] Fix DEBUG_VERBOSE print of uninitialized Result::endRemaining Point writes are recorded with the 2-argument interleaved_insert::Result constructor, which left endRemaining (and nextRangeWrite) indeterminate. The Phase 2 debug print then unconditionally printed endRemaining, so any DEBUG_VERBOSE && !NDEBUG build read an indeterminate span and, with stack garbage from a previous call, dereferenced a freed pointer. Initialize the range-only members in both constructors, and only print the end search path/spans for range writes. --- ConflictSet.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 553fb11..247c331 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -3904,11 +3904,12 @@ struct Result { Result() = default; Result(Node *insertionPoint, TrivialSpan remaining) : insertionPoint(insertionPoint), remaining(remaining), - endInsertionPoint(nullptr) {} + endInsertionPoint(nullptr), endRemaining{}, nextRangeWrite(nullptr) {} Result(Node *insertionPoint, TrivialSpan remaining, Node *endInsertionPoint, TrivialSpan endRemaining) : insertionPoint(insertionPoint), remaining(remaining), - endInsertionPoint(endInsertionPoint), endRemaining(endRemaining) {} + endInsertionPoint(endInsertionPoint), endRemaining(endRemaining), + nextRangeWrite(nullptr) {} Node *insertionPoint; TrivialSpan remaining; @@ -4979,9 +4980,11 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { fprintf(stderr, "search path: %s, begin: %s\n", getSearchPathPrintable(b).c_str(), printable(context.results[i].remaining).c_str()); - fprintf(stderr, "search path: %s, end: %s\n", - getSearchPathPrintable(e).c_str(), - printable(context.results[i].endRemaining).c_str()); + if (e != nullptr) { + fprintf(stderr, "search path: %s, end: %s\n", + getSearchPathPrintable(e).c_str(), + printable(context.results[i].endRemaining).c_str()); + } } #endif