Description
I recently attempted to update the R bindings for hnswlib but there is a valgrind problem of the form:
==217201== Conditional jump or move depends on uninitialised value(s)
==217201== at 0x188D9AB5: hnswlib::HierarchicalNSW<float>::searchKnn(void const*, unsigned long) const (packages/tests-vg/RcppHNSW/src/../inst/include/hnswalg.h:1150)
This should also be triggerable via the second Python bindings example on the current README (the code after "An example with updates after serialization/deserialization").
The problem line:
Line 1150 in 443d667
I believe the issue is that not all HierarchicalNSW
constructors are initializing all of their data members. Specifically num_deleted_
is a problem: while it can be incremented in loadIndex
under circumstances where isMarkDeleted
returns true, it's never actually assigned. In the example above, there isn't any deletion so the problem doesn't become apparent until searchKnn
is invoked.
I haven't checked for the validity of other class member variables so other problems may be lurking. I can certainly help with providing a PR or helping with testing, but I haven't updated the R bindings for a couple of years so more recent functionality isn't tested (yet). So this will for sure need some extra eyes on it.