You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GlobalLoggerRegistry::instance() currently uses Meyer's Singleton pattern, which can cause Static Destruction Order Fiasco (SDOF) when accessed during static destruction phase.
Problem
Current Implementation (global_logger_registry.h:335-337)
Apply Intentional Leak pattern to GlobalLoggerRegistry::instance():
static GlobalLoggerRegistry& instance() {
// Intentionally leak to avoid static destruction order issues// Registry may be accessed during other singletons' destructionstatic GlobalLoggerRegistry* instance = newGlobalLoggerRegistry();
return *instance;
}
Also apply to null_logger() (global_logger_registry.h:340-343):
static std::shared_ptr<ILogger> null_logger() {
// Intentionally leak to avoid static destruction order issuesstaticauto* null_logger_instance = new std::shared_ptr<NullLogger>(std::make_shared<NullLogger>());
return *null_logger_instance;
}
Benefits
Complete SDOF prevention: Registry remains valid throughout process lifetime
No behavioral changes: API remains identical
Minimal memory impact: Single instance (~few hundred bytes) leaked at process termination, reclaimed by OS
Summary
GlobalLoggerRegistry::instance()currently uses Meyer's Singleton pattern, which can cause Static Destruction Order Fiasco (SDOF) when accessed during static destruction phase.Problem
Current Implementation (
global_logger_registry.h:335-337)Root Cause
When
thread_systemcomponents (e.g.,thread_pool,thread_context) are destroyed during static destruction:thread_contextholdsstd::shared_ptr<ILogger>obtained fromGlobalLoggerRegistryGlobalLoggerRegistryis destroyed beforethread_pool, theILoggerimplementation stored inside the registry becomes invalidis_shutting_down()guards inthread_context::log(), thelogger_member itself may reference destroyed memoryDestruction Chain
Proposed Solution
Apply Intentional Leak pattern to
GlobalLoggerRegistry::instance():Also apply to
null_logger()(global_logger_registry.h:340-343):Benefits
thread_system'sthread_loggeralready uses this pattern (refactor: Extract generic enum serialization template to eliminate duplication #293)Related Issues
Acceptance Criteria
GlobalLoggerRegistry::instance()to Intentional Leak patternnull_logger()to Intentional Leak pattern