From e899476ceb8e21d1739851e2d7d6c0c70cac43e5 Mon Sep 17 00:00:00 2001 From: Justin Gibbs Date: Thu, 9 Apr 2026 21:52:26 -0700 Subject: [PATCH] Default-initialize SVSStorageKind in IndexSVSVamana (#5054) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5054 `IndexSVSVamana::storage_kind` was declared without a default initializer, and the default constructor is `= default`, so the field was left uninitialized in default-constructed instances. This is undefined behavior any time the value is read — including serialization via `write_index`, which writes the garbage value to disk. Add `= SVS_FP32` as the default initializer, matching the default used by the parameterized constructor `IndexSVSVamana(d, degree, metric, storage)`. This is a safe, behavior-preserving change: - The parameterized constructor already defaults to `SVS_FP32`, so any code constructing an index with arguments is unaffected. - The two derived classes (`IndexSVSVamanaLVQ`, `IndexSVSVamanaLeanVec`) explicitly set `storage_kind` in their own default constructors, so they are also unaffected. - The only code path that changes behavior is default construction of `IndexSVSVamana` itself, which previously produced an uninitialized (UB) value and now produces `SVS_FP32`. Reviewed By: mnorris11 Differential Revision: D99891611 fbshipit-source-id: da6acff7bdeb5668a2bf5f3b585bc1a3179004b9 --- faiss/svs/IndexSVSVamana.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faiss/svs/IndexSVSVamana.h b/faiss/svs/IndexSVSVamana.h index 081f4c0e4..65d514a80 100644 --- a/faiss/svs/IndexSVSVamana.h +++ b/faiss/svs/IndexSVSVamana.h @@ -86,7 +86,7 @@ struct IndexSVSVamana : Index { size_t max_candidate_pool_size = 200; bool use_full_search_history = true; - SVSStorageKind storage_kind; + SVSStorageKind storage_kind = SVS_FP32; IndexSVSVamana();