Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Memory Leak in Labels in VCL #194

Open
ifadams opened this issue Jul 24, 2024 · 0 comments
Open

Potential Memory Leak in Labels in VCL #194

ifadams opened this issue Jul 24, 2024 · 0 comments
Labels
Bug Indicates unexpected or undesired behaviors

Comments

@ifadams
Copy link
Contributor

ifadams commented Jul 24, 2024

Describe the bug
in the discriptorset add and add_n_store functions labels are copied to a memory location that goes out of scope.

Additional context
Labels are added for descriptor set to store class ids (integer values) or some strings.

The labels are later used in the function classify for majority vote on the labels
void DescriptorSet::classify(DescDataArray descriptors, unsigned n, long *labels, unsigned quorum)

The labels are set with the descriptorset insert functions when labels are not null

  • add(float *descriptors, unsigned n_descriptors, long *labels)"
  • add_and_store(float *descriptors, unsigned n_descriptors, long *labels)

these are mapped to the corresponding functions for each engine supported (FAISS, FLINNG, TileDB)

E.g. Faiss Engine (similar behavior with other engines) add function when the labels are not null, it copies labels to an unused memory location without setting the correct data structure and then returns

https://github.com/intel-inersource/libraries.databases.visual.vdms/blob/a96e8e21fef9ca369cb106eed5c7e4963e23ad11/src/vcl/FaissDescriptorSet.cc#L100

if (labels != NULL) {
_label_ids.resize(_index->ntotal + n);
long *dst = _label_ids.data() + _index->ntotal;
std::memcpy(dst, labels, n * sizeof(long));
}

The appropriate functions to correctly set the labels should be called.

example:
void DescriptorSet::set_labels_map(LabelIdVector &ids, std::vectorstd::string &labels) should be used to store the labels when the type of the labels is string and similar function (not implemented) for other types of labels.

@ifadams ifadams added the Bug Indicates unexpected or undesired behaviors label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indicates unexpected or undesired behaviors
Projects
None yet
Development

No branches or pull requests

1 participant