Skip to content

Fix memory out-of-bounds access when ex_bits is 0 in HNSW search#42

Open
Light-V wants to merge 1 commit intoVectorDB-NTU:mainfrom
Light-V:main
Open

Fix memory out-of-bounds access when ex_bits is 0 in HNSW search#42
Light-V wants to merge 1 commit intoVectorDB-NTU:mainfrom
Light-V:main

Conversation

@Light-V
Copy link

@Light-V Light-V commented Mar 20, 2026

Description

This PR fixes a memory out-of-bounds access bug in the HNSW search functionality.

Problem

When ex_bits_ is 0, the get_full_est function accesses non-existent ex_data, causing out-of-bounds memory access.

Solution

Added a check before calling get_full_est in searchBaseLayerST_AdaptiveRerankOpt. When ex_bits_ is 0, we use get_bin_est instead, which is the correct behavior since there is no additional refinement data available.

Changes

  • Modified searchBaseLayerST_AdaptiveRerankOpt to check ex_bits_ before calling get_full_est

Testing

The fix has been tested locally and resolves the issue without introducing performance overhead in the common case (ex_bits > 0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant