Skip to content

Commit ef28c6b

Browse files
scsiguymeta-codesync[bot]
authored andcommitted
Fix uncaught exceptions in IndexIVF::search_preassigned OpenMP region (#5037)
Summary: Pull Request resolved: #5037 C++ exceptions thrown inside `#pragma omp parallel` regions that are not caught within the region call `std::terminate` — they cannot propagate across thread boundaries. `IndexIVF::search_preassigned` had multiple unguarded throw sites inside its OpenMP parallel region: 1. **`scan_one_list` lambda**: `FAISS_THROW_IF_NOT_FMT(key < nlist)` and `scanner->set_list()` were above the try-catch block, so a corrupt key >= nlist would throw uncaught and call `std::terminate`. 2. **Outer parallel region**: `get_InvertedListScanner()` and `scanner->set_query()` had no try-catch at all. Fixes: 1. Moved the existing try-catch in `scan_one_list` up to also cover the key validation and `set_list` calls. 2. Wrapped the entire `#pragma omp parallel` body in a try-catch that uses the existing `interrupt`/`exception_string`/`exception_mutex` pattern to safely propagate exceptions out of the parallel region. Reviewed By: mnorris11 Differential Revision: D99455250 fbshipit-source-id: 41e8816d71c031b1e8526f76bd5a8936f4d4f160
1 parent 8d8881e commit ef28c6b

2 files changed

Lines changed: 252 additions & 195 deletions

File tree

0 commit comments

Comments
 (0)