facebookresearch / facebookresearch/faiss

A possible memory leak when an exception is thrown

Open
#1,963 1 comment 0 reactions 0 assignees View on GitHub
enhancement Performance
Dominant language
C++
Stars
40.9k
Forks
4.5k
PR merge metrics
No merged PRs in 30d

Description

In file faiss/impl/index_read.cpp, function `read_VectorTransform(IOReader* f)`.

Those pointers allocated by `new` (`pca`, `rdt`, `nt`, etc.) might leak when an exception is thrown.

`READ1`, `READVECTOR` and those `FAISS_THROW_XXX` could all throw exceptions.

I think it'll be better to wrap those raw pointers by smart pointers.

Contributor guide

Open the contributing guide

Research direction

Start in faiss/impl/index_read.cpp at read_VectorTransform(IOReader* f), and trace the pca, rdt, nt and other allocations alongside READ1, READVECTOR and the FAISS_THROW_XXX paths. Confirm that exceptions during each read do not leave allocated objects unreleased; done means the function is exception-safe without changing successful reads.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.