facebookresearch / facebookresearch/faiss
A possible memory leak when an exception is thrown
- 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
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