Skip to content

Fix: Patch usearch tombstone bug in equal_range iterator - #3899

Merged
DavIvek merged 1 commit into
masterfrom
fix-usearch-tombstone-iterator
Mar 12, 2026
Merged

DavIvek merged 1 commit into
masterfrom
fix-usearch-tombstone-iterator

Conversation

@DavIvek

@DavIvek DavIvek commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

The equal_range iterator in flat_hash_multi_set_gt did not check the deleted flag when advancing, causing it to yield tombstone entries as live matches. In index_dense_gt::remove() this caused already-freed slots to be pushed to free_keys_ again, corrupting size() accounting and leading to crashes ("cannot create std::vector larger than max_size").

Usearch related PR: unum-cloud/USearch#727

The equal_range iterator in flat_hash_multi_set_gt did not check the
deleted flag when advancing, causing it to yield tombstone entries as
live matches. In index_dense_gt::remove() this caused already-freed
slots to be pushed to free_keys_ again, corrupting size() accounting
and leading to crashes ("cannot create std::vector larger than max_size").

Upstream PR: unum-cloud/USearch#727
@DavIvek DavIvek added this to the mg-v3.9.0 milestone Mar 12, 2026
@DavIvek DavIvek self-assigned this Mar 12, 2026
@DavIvek DavIvek added bug bug Docs - changelog only Docs - changelog only CI -build=debug -test=core Run debug build and core tests on push CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push CI -build=release -test=stress Run release build and stress tests on push labels Mar 12, 2026
@DavIvek

DavIvek commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Tracking

  • [Link to Epic/Issue]

Standard development

CI Testing Labels

  • Select the appropriate CI test labels (CI -build=build-name -test=test-suite)

Documentation checklist

  • Add the documentation label
  • Add the bug / feature label
  • Add the milestone for which this feature is intended
    • If not known, set for a later milestone
  • Write a release note, including added/changed clauses
    • Fixed a bug in flat_hash_multi_set_gt where the equal_range iterator incorrectly yielded tombstone (deleted) entries as live matches, causing double-frees in index_dense_gt::remove() that corrupted size accounting and led to crashes. Users running workloads with frequent deletions on dense indexes were at risk of hitting this crash. #3899
  • [ Documentation PR link memgraph/documentation#XXXX ]
    • Is back linked to this development PR

@DavIvek
DavIvek requested a review from as51340 March 12, 2026 09:52
@sonarqubecloud

Copy link
Copy Markdown

@DavIvek
DavIvek added this pull request to the merge queue Mar 12, 2026
@DavIvek
DavIvek removed this pull request from the merge queue due to a manual request Mar 12, 2026
@DavIvek
DavIvek added this pull request to the merge queue Mar 12, 2026
Merged via the queue into master with commit 07cca29 Mar 12, 2026
39 checks passed
@DavIvek
DavIvek deleted the fix-usearch-tombstone-iterator branch March 12, 2026 18:06
@gitbuda gitbuda mentioned this pull request Mar 18, 2026
68 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug bug CI -build=debug -test=core Run debug build and core tests on push CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push CI -build=release -test=stress Run release build and stress tests on push Docs - changelog only Docs - changelog only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants