Antti Määttä 54d6769456 Fix recursion in QLoggingRegistry
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>
2025-04-24 06:38:17 +00:00
2024-11-05 14:36:16 +01:00
2024-11-05 14:36:16 +01:00
2025-04-24 06:38:17 +00:00
2025-04-15 06:57:06 +01:00
2025-04-15 06:57:06 +01:00
2025-03-25 08:40:27 +00:00
2024-06-25 11:44:00 +02:00
Description
Qt Base (Core, Gui, Widgets, Network, ...)
822 MiB
Languages
C++ 84.3%
HTML 4.9%
C 3.9%
CMake 3.6%
Objective-C++ 2%
Other 0.8%