Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Foundation/src/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,24 @@ void Logger::shutdown()
{
Mutex::ScopedLock lock(_mapMtx);

_pLoggerMap.reset();
if (_pLoggerMap)
{
// Detach the channel from every Logger instead of destroying the
// map. Long-lived objects frequently cache a Logger& obtained via
// Logger::get() during construction and may still dereference it
// from static destructors that run after LoggingSubsystem has
// called shutdown(); tearing the map down there would leave those
// references dangling (heap-use-after-free).
//
// logImpl() already guards channel writes with `if (_pChannel)`, so
// a Logger with a null channel is a safe no-op. The map (and the
// Logger objects it keeps alive) are released when the static
// _pLoggerMap is destroyed at process exit.
for (auto& p: *_pLoggerMap)
{
p.second->setChannel(nullptr);
}
}
}


Expand Down