aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-05-27 10:03:00 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-05-31 17:23:09 +0200
commit0434e54b55d9a31c3b5331856bab639b7149058c (patch)
tree306dd5766f4dbb12c0242d09d1d8c742485f1620 /src/qml/debugger
parentc98c2c08a5f926b67c40b6363274d23066bfe341 (diff)
Fix race condition on QQmlEnginePrivate::qml_debugging_enabled
C++11 allows static dynamic initialization from different TUs to happen concurrently, which means the QQmlDebuggingEnabler ctor must be re-entrant and synchronized with other users of qml_debugging_enabled. Thankfully, this is just a flag, so the fix is to simply make it atomic<> and use relaxed loads and stores on it. Pick-to: 6.3 6.2 5.15 Change-Id: I0305ab55be86a0e286016a3d1d97ee9bc0e28070 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/debugger')
-rw-r--r--src/qml/debugger/qqmldebug.cpp2
-rw-r--r--src/qml/debugger/qqmldebugconnector.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/qml/debugger/qqmldebug.cpp b/src/qml/debugger/qqmldebug.cpp
index 5619a5fe3e..4044612793 100644
--- a/src/qml/debugger/qqmldebug.cpp
+++ b/src/qml/debugger/qqmldebug.cpp
@@ -63,7 +63,7 @@ QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning)
{
if (printWarning && !s_printedWarning.test_and_set(std::memory_order_relaxed))
fprintf(stderr, "QML debugging is enabled. Only use this in a safe environment.\n");
- QQmlEnginePrivate::qml_debugging_enabled = true;
+ QQmlEnginePrivate::qml_debugging_enabled.store(true, std::memory_order_relaxed);
}
/*!
diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp
index dabe6bfabe..0077e655bb 100644
--- a/src/qml/debugger/qqmldebugconnector.cpp
+++ b/src/qml/debugger/qqmldebugconnector.cpp
@@ -111,7 +111,7 @@ QQmlDebugConnector *QQmlDebugConnector::instance()
if (!params)
return nullptr;
- if (!QQmlEnginePrivate::qml_debugging_enabled) {
+ if (!QQmlEnginePrivate::qml_debugging_enabled.load(std::memory_order_relaxed)) {
if (!params->arguments.isEmpty()) {
qWarning().noquote() << QString::fromLatin1(
"QML Debugger: Ignoring \"-qmljsdebugger=%1\". Debugging "