Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5053
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::range_search_preassigned` had the same class of bugs fixed in
`search_preassigned` by D99455250:
1. **`scan_list_func` lambda**:
`FAISS_THROW_IF_NOT_FMT(key < nlist)` was above the try-catch block,
so a corrupt key >= nlist would throw uncaught and call
`std::terminate`.
2. **Outer parallel region**:
`get_InvertedListScanner()`, `scanner->set_query()`, and
`FAISS_THROW_IF_NOT(scanner.get())` had no try-catch at all.
Fixes:
1. Moved the existing try-catch in `scan_list_func` up to also cover the
key validation.
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: D99879998
fbshipit-source-id: e768372cbaf8a22a9459fc3fd9b9df6e019897a6