Skip to content

Commit 4776c4d

Browse files
committed
Fix logging mutex crash at exit on macOS
1 parent 860d085 commit 4776c4d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

onnxruntime/core/common/logging/logging.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ LoggingManager* LoggingManager::GetDefaultInstance() {
6565
#endif
6666

6767
static std::mutex& DefaultLoggerMutex() noexcept {
68-
static std::mutex mutex;
69-
return mutex;
68+
// Use dynamically allocated mutex to avoid destruction order issues.
69+
// The mutex is intentionally never deleted to ensure it remains valid
70+
// during static destruction when LoggingManager destructor may be called.
71+
static std::mutex* mutex = new std::mutex();
72+
return *mutex;
7073
}
7174

7275
Logger* LoggingManager::s_default_logger_ = nullptr;

0 commit comments

Comments
 (0)