repairDatabaseAndCheckVersion calls rebuildIndexes before attempting to call repairDatabase (which also rebuild indexes).
If there are indexes to rebuild, this will trigger a null pointer dereference as a result of setting the RecordStore to nullptr (intentionally) when the catalog initializes the collections when started with --repair.
Indexes will be rebuilt if reconcileCatalogAndIdents has an index in the catalog that does not exist in the storage engine. This would normally be safe when starting from an unclean shutdown.
If the database is started with --repair, do not call rebuildIndexes before repairing databases.