Skip to content
Snippets Groups Projects
Commit 51c78246 authored by John Chapman's avatar John Chapman
Browse files

Protection against calling G4ThreadInitTool::terminateThread without having called initThread

Based on the discussion in ATLASSIM-4062, it seems that with the new version of TBB introduced
in `LCG_95` (see !21493) can sometimes try to call `G4ThreadInitTool::terminateThread` without
having first called `G4ThreadInitTool::initThread`. This causes the `G4ExHive-test` CI test
to fail at random. Adding some protection to `G4ThreadInitTool::terminateThread` to prevent
crashes in this case while the experts follow up with the TBB experts.
parent ba6b9d40
No related branches found
No related tags found
No related merge requests found
......@@ -114,12 +114,23 @@ void G4ThreadInitTool::initThread()
//-----------------------------------------------------------------------------
void G4ThreadInitTool::terminateThread()
{
ATH_MSG_INFO("terminateThread ==> tbb thread 0x" <<
ATH_MSG_DEBUG("terminateThread ==> tbb thread 0x" <<
std::hex << pthread_self() << std::dec);
// Geant4 worker finalization
G4RunManager::GetRunManager()->RunTermination();
// Atomic decrement number of initialized threads
m_nInitThreads--;
auto runMgr = G4RunManager::GetRunManager();
ATH_MSG_DEBUG("G4RunManager ptr" << runMgr);
if(runMgr) {
runMgr->RunTermination();
ATH_MSG_INFO("terminateThread ==> safely called G4AtlasWorkerRunManager::RunTermination for tbb thread 0x" <<
std::hex << pthread_self() << std::dec);
// Atomic decrement number of initialized threads
m_nInitThreads--;
}
else {
ATH_MSG_WARNING("skipping attempt to call terminateThread for tbb thread 0x" <<
std::hex << pthread_self() << std::dec <<
" without having first called initThread.");
// Not decrementing m_nInitThreads as initThread was not called in this case.
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment