fix(storage): guard CSR getGroup against stale/OOB group indices (SIGSEGV)#610
Closed
rysweet wants to merge 1 commit into
Closed
fix(storage): guard CSR getGroup against stale/OOB group indices (SIGSEGV)#610rysweet wants to merge 1 commit into
rysweet wants to merge 1 commit into
Conversation
…SEGV) Relationship delete + checkpoint churn can leave a stale row in csrIndex->indices[nodeOffset] that maps (via getQuotientRemainder of an INVALID_ROW_IDX sentinel) to an out-of-range chunk-group index. getGroup then performed an out-of-bounds std::vector access and callers dereferenced the result, crashing with SIGSEGV during the consolidation/ checkpoint phase (getGroup(groupIdx=UINT32_MAX)). GroupCollection::getGroup/getGroupNoLock now return nullptr for an out-of-range index instead of an OOB access, and every CSRNodeGroup deref site (scan, update, delete_, checkpoint insertion-write, and the two checkpoint-collect isDeleted loops) handles nullptr by skipping / treating the stale row as deleted. This matches the engine's existing INVALID_ROW_IDX skip in the insertion loop. Reproduced and fixed via a 120-iteration delete+checkpoint churn test in amplihack-memory (issue LadybugDB#100): the workload previously SIGSEGV'd mid-churn in collectInMemRegionChangesAndUpdateHeaderLength and now completes cleanly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
|
Withdrawing this PR — it was opened prematurely. Closing to validate the fix and CI in a private fork first; will re-open a clean, CI-green PR if appropriate. Apologies for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A long-running process doing relationship deletes + checkpoints crashes with
SIGSEGVduring the consolidation/checkpoint phase. The faulting access isGroupCollection<ChunkedNodeGroup>::getGroup(groupIdx = 4294967295 / UINT32_MAX).Root cause
After relationship delete + checkpoint churn,
csrIndex->indices[nodeOffset]canretain a stale row (an
INVALID_ROW_IDXsentinel).getQuotientRemainder(INVALID_ROW_IDX)yields an out-of-range chunk-group index.
GroupCollection::getGrouponly had adebug-only
DASSERT(groupIdx < groups.size())(a no-op in release), so it performed anout-of-bounds
std::vectoraccess and callers dereferenced the result → undefinedbehavior /
SIGSEGV.The insertion-write loop in
checkpointColumnInRegionalready guards this case withif (row == INVALID_ROW_IDX) continue;, but the two checkpoint-collect loops(
collectInMemRegionChangesAndUpdateHeaderLengthandpopulateCSRLengthInMemOnly),plus the scan /
update/delete_paths, do not — they dereference thegetGroupresult directly.
Fix
GroupCollection::getGroup/getGroupNoLocknow returnnullptrfor an out-of-rangeindex instead of performing an OOB access.
CSRNodeGroupderef site handlesnullptr:scanCommittedInMemSequential/scanCommittedInMemRandom): skip / empty result;update: no-op (target row gone);delete_: returnsfalse;isDeletedloops: treat a stale/null group as deleted(purges the stale row via
turnToNonSequential()+setInvalid(i)), consistent withthe engine's existing handling of deleted rows.
This is version-independent (reproduced on 0.15.x–0.17.1) and present on current
main.Validation
Reproduced via a deterministic 120-iteration delete+checkpoint churn test (amplihack-memory
issue #100). Before:
SIGSEGVmid-churn incollectInMemRegionChangesAndUpdateHeaderLength.After (engine rebuilt from source with this patch): the workload completes cleanly and the
test passes.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com