Fix IVF extend list resize bug#2297
Conversation
|
old_used_size is the old logical size. old real size is checked via extends. |
in ivf-flat extend, resize_list() receives |
|
here is poc after base extend after grow extend BUG: index-visible size is 120 but internal list::size stayed 100 |
|
Ok, sorry for closing this prematurely, this does seem legit. I'm not sure though if this internal get_size() is used where it could cause any problems. I'll look into this in the following days. |
|
Thank you very much! I forgot to mention how i even stumbled upon this - i got very strange Illegal memory access errors (i am using python wrapper for multiple extends + search + torch for calculating the vectors) and believe that this bug is related (IMA was in calc_chunk_indices_kernel) |
Description
Fixes a bug in IVF-Flat and IVF-SQ
extend()where a list could receive new vectors but keep its old logicallist::size.The issue happens when extending a list that already has enough allocated capacity. Interleaved IVF list storage may be padded, so the old copy extent can be larger than the old logical size.
Example:
Previously,
resize_list()received only the padded value,128, and used it both for copying old storage and for deciding whetherlist::sizeneeded to be updated. It checked120 <= 128, skipped the update, and leftlist::size == 100even though new vectors were inserted up to120.This stale size can break the shared-list / copy-on-write logic in later extends and corrupt search results.
Fix
Pass separate old sizes to
ivf::resize_list():The existing overload is kept for call sites where both sizes are the same.
Tests
Added regression tests for: