From 6f5d56d994f04558604a6cc61cd220075871291b Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 6 Oct 2020 12:50:32 +0000 Subject: [PATCH] core(logger): avoid destruction of GlobalLoggingInitStruct object - keep logger available until the program termination --- modules/core/src/logger.cpp | 3 +-- platforms/scripts/valgrind.supp | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/core/src/logger.cpp b/modules/core/src/logger.cpp index 7dd6f93817..dbb25f9e09 100644 --- a/modules/core/src/logger.cpp +++ b/modules/core/src/logger.cpp @@ -94,8 +94,7 @@ LogLevel GlobalLoggingInitStruct::m_defaultUnconfiguredGlobalLevel = GlobalLoggi // static GlobalLoggingInitStruct& getGlobalLoggingInitStruct() { - static GlobalLoggingInitStruct globalLoggingInitInstance; - return globalLoggingInitInstance; + CV_SINGLETON_LAZY_INIT_REF(GlobalLoggingInitStruct, new GlobalLoggingInitStruct()); } // To ensure that the combined struct defined above is initialized even diff --git a/platforms/scripts/valgrind.supp b/platforms/scripts/valgrind.supp index 1fa1fff688..10ea856e9d 100644 --- a/platforms/scripts/valgrind.supp +++ b/platforms/scripts/valgrind.supp @@ -218,6 +218,13 @@ fun:__itt_*create* } +{ + OpenCV-SingletonLogger + Memcheck:Leak + ... + fun:_ZN2cv5utils7logging8internalL26getGlobalLoggingInitStructEv +} + { OpenCV-gtk_init Memcheck:Leak