Skip to content

valgrind problems when searching a reloaded index #393

Open
@jlmelville

Description

@jlmelville

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:

if (num_deleted_) {

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions