fix(interfaces): apply Intentional Leak pattern to GlobalLoggerRegistry#201
Merged
Merged
Conversation
Apply Intentional Leak pattern to GlobalLoggerRegistry::instance() and null_logger() static methods to prevent Static Destruction Order Fiasco (SDOF). Changes: - Change instance() to use heap-allocated pointer that is never deleted - Change null_logger() to use heap-allocated shared_ptr - Add documentation comments explaining the pattern choice The registry and null logger may be accessed during other static objects' destruction, so they must remain valid throughout the entire process lifetime. The leaked memory is minimal (~few hundred bytes) and is reclaimed by the OS at process termination. Fixes #200
Update SINGLETON_GUIDELINES.md and SINGLETON_GUIDELINES_KO.md to reflect that GlobalLoggerRegistry now uses the Intentional Leak pattern. Changes: - Update audit results table with new pattern and resolved status - Update detailed analysis section with current implementation - Add memory impact information
6 tasks
kcenon
added a commit
that referenced
this pull request
Apr 13, 2026
…ry (#201) * fix(interfaces): apply Intentional Leak pattern to GlobalLoggerRegistry Apply Intentional Leak pattern to GlobalLoggerRegistry::instance() and null_logger() static methods to prevent Static Destruction Order Fiasco (SDOF). Changes: - Change instance() to use heap-allocated pointer that is never deleted - Change null_logger() to use heap-allocated shared_ptr - Add documentation comments explaining the pattern choice The registry and null logger may be accessed during other static objects' destruction, so they must remain valid throughout the entire process lifetime. The leaked memory is minimal (~few hundred bytes) and is reclaimed by the OS at process termination. Fixes #200 * docs: update singleton guidelines for GlobalLoggerRegistry #200 Update SINGLETON_GUIDELINES.md and SINGLETON_GUIDELINES_KO.md to reflect that GlobalLoggerRegistry now uses the Intentional Leak pattern. Changes: - Update audit results table with new pattern and resolved status - Update detailed analysis section with current implementation - Add memory impact information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GlobalLoggerRegistry::instance()andnull_logger()to prevent Static Destruction Order Fiasco (SDOF)Changes
Code Changes
GlobalLoggerRegistry::instance(): Changed from Meyer's Singleton to heap-allocated pointer that is never deletednull_logger(): Changed from static local to heap-allocatedshared_ptr<NullLogger>Documentation Updates
SINGLETON_GUIDELINES.mdandSINGLETON_GUIDELINES_KO.mdRationale
The registry and null logger may be accessed during other static objects' destruction (e.g., when
thread_contextlogs duringthread_pooldestruction). The Intentional Leak pattern ensures these objects remain valid throughout the entire process lifetime.Memory impact is minimal (~200 bytes for registry + ~32 bytes for null_logger) and is reclaimed by the OS at process termination.
Test plan
Fixes #200