#13883 SummaryEnsemble: Replace deleteChildrenAsync with synchronous delete to fix race

deleteChildrenAsync() spawns a std::thread that deletes old RimFileSummaryCase
objects concurrently with the OpenMP parallel loop in loadFileSummaryCaseData().
#pragma omp critical only synchronizes OMP threads, not std::threads, so OPM/HDF5
library state was accessed simultaneously from both, causing crashes.

Replace with clearWithoutDelete() + synchronous delete to preserve the observer
signal disconnection fix from #12262 while eliminating the thread race.
This commit is contained in:
Magne Sjaastad committed 2026-04-16 16:43:36 +02:00
1 parent 5c35592f3a
commit 639024eca4
2 files changed
+15 -2

No files matched your search

@@ -202,7 +202,13 @@ RimSummaryCase* RimSummaryEnsemble::firstSummaryCase() const
//--------------------------------------------------------------------------------------------------
void RimSummaryEnsemble::replaceCases( const std::vector<RimSummaryCase*>& summaryCases, bool notifyChange )
{
m_cases.deleteChildrenAsync();
// Delete synchronously to prevent a race between the std::thread spawned by
// deleteChildrenAsync() and any active OpenMP parallel loop in loadFileSummaryCaseData().
// clearWithoutDelete() disconnects observer signals first (preserves the fix for #12262).
auto casesToDelete = m_cases.childrenByType();
m_cases.clearWithoutDelete();
for ( auto* c : casesToDelete )
delete c;
if ( summaryCases.empty() ) return;