A std::optional<IndexDatabase> left empty by a throwing ReadOnly emplace is dereferenced for the next file
Symptom#
A segfault when several files share one index: after one file's index open throws, the next file of the same index crashes.
Cause#
std::optional<IndexDatabase> was left empty after a throwing ReadOnly emplace, then dereferenced for the next file of the same index.
Fix#
Check the optional (or handle the failed open) before dereferencing it for the next file. Found while adding catalog-on-demand (scan::ensure_catalog runs a CatalogFold-only scan with all_records=true before wildcard expansion and View::columns/column_info/schema_tree; all_records is needed because the genesis data filter gtype!=run otherwise makes the scan "filtered" and the fold never attaches).
Evidence#
Fixed in dftracer-utils commit 4e3867da. Open follow-ups are in docs/plans/2026-10-04-single-pass.md.
Also found by searching
- segfault after a throwing std::optional emplace of IndexDatabase
- optional left empty after exception then dereferenced for the next file of the same index
- ensure_catalog read-only IndexDatabase open fails