Skip to content
Snippets Groups Projects
Commit 604b7212 authored by Scott Snyder's avatar Scott Snyder Committed by Melissa Yexley
Browse files

AthAllocators: Fix potential deadlock.

AthAllocators: Fix potential deadlock.

In ArenaHeader::allocator(), we need to release the header lock
before creating the LockedAllocator instance.  Otherwise we can deadlock
if an algorithm creates multiple allocators.

See ATR-28749.
parent 76e3aeb6
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
// $Id: ArenaHeader.icc 470529 2011-11-24 23:54:22Z ssnyder $
......@@ -41,16 +41,19 @@ LockedAllocator ArenaHeader::allocator (size_t i)
inline
LockedAllocator ArenaHeader::allocator (const EventContext& ctx, size_t i)
{
ArenaBase* a = nullptr;
size_t slot = ctx.slot();
{
std::lock_guard<std::mutex> lock (m_mutex);
if (slot < m_slots.size()) {
ArenaBase* a = m_slots[slot];
if (a) {
return a->allocator (i);
}
a = m_slots[slot];
}
}
// Need to release the header lock before creating the allocator;
// otherwise we can deadlock (ATR-28749).
if (a) {
return a->allocator (i);
}
return allocator (i);
}
......
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