QLoggingRegistry relies on any Qt code it uses not having category logging in it, because it causes a global variable to be recursively initialized. This has been the case so far, but with CTF tracing enabled, there is Qt code that uses category logging if the first tracing event originates from a logging category, causing the tracing library to be loaded. It is undefined behavior to recurse into the initialization. Here is the backtrace of the situation: QGlobalStatic<QtGlobalStatic::Holder<()::Q_QGS_qtLoggingRegistry> >::instance QGlobalStatic<QtGlobalStatic::Holder<()::Q_QGS_qtLoggingRegistry> >::operator() QLoggingRegistry::instance QLoggingCategoryWithEnvironmentOverride::registerOverride QLoggingCategoryWithEnvironmentOverride::QLoggingCategoryWithEnvironmentOverride QtPrivateLogging::qt_lcDebugPlugins locatePlugin QPluginLoader::setFileName QPluginLoader::QPluginLoader loadPlugin initialize _tracepoint_enabled QtPrivate::trace_QObject_ctor QObject::QObject ... QFile::QFile loadRulesFromFile QLoggingRegistry::initializeRules QLoggingRegistry::QLoggingRegistry (anonymous namespace)::Q_QGS_qtLoggingRegistry::innerFunction QtGlobalStatic::Holder<::Q_QGS_qtLoggingRegistry>::Holder QGlobalStatic<QtGlobalStatic::Holder<::Q_QGS_qtLoggingRegistry> >::instance QGlobalStatic<QtGlobalStatic::Holder<::Q_QGS_qtLoggingRegistry> >::operator() QLoggingRegistry::instance QLoggingCategory::setFilterRules main Add a recursion guard in the QLoggingRegistry that causes QLoggingRegistry::instance to return null if recursion occurs. The internal code appears to handle nullptr well, while external code should always receive a non-null pointer. Fixes: QTBUG-135326 Pick-to: 6.8 Change-Id: I91f1ff341b096031930004cca8421f2ee0bab9b1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 07255301eaa288fde3d550e0119b4d3ed2c39d22) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
…
…
Description
Languages
C++
84.3%
HTML
4.9%
C
3.9%
CMake
3.6%
Objective-C++
2%
Other
0.8%