diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-01-10 18:10:48 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-01-12 12:44:38 +0100 |
commit | 4a4240f1bdf184a52a22b94f37090b07434770e7 (patch) | |
tree | 936b84e3fefd72e4f97be10877326d710f80dedf /src/corelib/thread/qthread_p.h | |
parent | e9fd1c6aab28f027760da76ebc154f0ff9aefcf8 (diff) |
Don't access QObject::objectName during QThread start
This is a data race, as the thread accesses QObject::objectName on the
QThread instance while the thread owning the QThread might modify the
objectName.
Instead, make a copy in the QThreadPrivate that can be accessed safely.
Task-number: QTBUG-96718
Pick-to: 6.3 6.2 5.15
Change-Id: I10701551d498993ca5055daf161636bfb648840c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/thread/qthread_p.h')
-rw-r--r-- | src/corelib/thread/qthread_p.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 0a3813ab3b..aa6183f7e2 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -201,6 +201,13 @@ public: QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit)); } } + +#ifndef Q_OS_INTEGRITY +private: + // Used in QThread(Private)::start to avoid racy access to QObject::objectName, + // unset afterwards. On INTEGRITY we set the thread name before starting it. + QString objectName; +#endif }; #else // QT_CONFIG(thread) |