From 66ee534fba6c42e03677bc6d7666eb64aec1e182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 13 Oct 2023 13:41:16 +0200 Subject: SignalDumper: fix UB (data race on ignoreLevel) ... by making it thread_local. It is written and read by multiple threads at the same time, so it needs to be protected. Since signal emission start and end happens in a single thread, keep it thread_local rather than using an atomic. Change-Id: I98fc5438c512b45f936318be31a6fccbe5b66944 Reviewed-by: Marc Mutz (cherry picked from commit 744e9a69ab4965561529f66d8872b6c2455f4fca) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 73cae2903bb009db17bdf0d4d5ba7685f7974761) Reviewed-by: Edward Welbourne --- src/testlib/qsignaldumper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib/qsignaldumper.cpp b/src/testlib/qsignaldumper.cpp index f0c35b92f9..54b608ed50 100644 --- a/src/testlib/qsignaldumper.cpp +++ b/src/testlib/qsignaldumper.cpp @@ -25,7 +25,7 @@ inline static void qPrintMessage(const QByteArray &ba) Q_GLOBAL_STATIC(QList, ignoreClasses) Q_CONSTINIT thread_local int iLevel = 0; -static int ignoreLevel = 0; +Q_CONSTINIT thread_local int ignoreLevel = 0; enum { IndentSpacesCount = 4 }; static void qSignalDumperCallback(QObject *caller, int signal_index, void **argv) -- cgit v1.2.3