Fix buffer overflow in k-mer prefilter with highly conserved sequences#1091
Open
mzueva wants to merge 1 commit intosoedinglab:masterfrom
Open
Fix buffer overflow in k-mer prefilter with highly conserved sequences#1091mzueva wants to merge 1 commit intosoedinglab:masterfrom
mzueva wants to merge 1 commit intosoedinglab:masterfrom
Conversation
… at most half the bin entries can be duplicates, but with repetitive k-mer hits (e.g. antibody frameworks) elementCount can approach currBinSize, causing out-of-bounds writes. Use elementCount directly for a correct bound.
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.
CacheFriendlyOperations::findDuplicatesunderestimates output size when checking for buffer overflow. The check usesstd::min(elementCount, currBinSize/2), assuming at most half of bin entries are duplicates. This assumption breaks when query k-mers are shared across a large fraction of the target database — as it happens with antibody variable region sequences, where conserved framework k-mers match ~70% of targets on consistent diagonals. The result is silent out-of-bounds writes to the foundDiagonals buffer, causing segfaults during prefiltering. With multiple threads, the corruption typically crashes at low progress (~8%).To reproduce: run mmseqs easy-search with an antibody query against a multi-million antibody database (e.g. 10M clonotype sequences). Any dataset where conserved k-mers match a large fraction of targets will trigger it.
To fix: replace
std::min(elementCount, currBinSize/2)withelementCountfor a correct upper bound.