From b58af67d7b5f22eaf2916b91d8a7060781203561 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 14 Feb 2017 12:13:53 -0800 Subject: Turn QThreadData::threadId into a QAtomicPointer Solves a data race found by TSan. Since thread and threadId are QAtomicPointer, I've removed the explicit initialization in the QThreadData constructor Task-number: QTBUG-58855 Change-Id: I4139d5f93dcb4b429ae9fffd14a34082f2683f76 Reviewed-by: Marc Mutz --- src/corelib/thread/qthread_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/thread/qthread_win.cpp') diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index e6c70ecb55..ef7bfc511d 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -137,7 +137,7 @@ QThreadData *QThreadData::current(bool createIfNecessary) } threadData->deref(); threadData->isAdopted = true; - threadData->threadId = reinterpret_cast(quintptr(GetCurrentThreadId())); + threadData->threadId.store(reinterpret_cast(quintptr(GetCurrentThreadId()))); if (!QCoreApplicationPrivate::theMainThread) { QCoreApplicationPrivate::theMainThread = threadData->thread.load(); @@ -351,7 +351,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi qt_create_tls(); TlsSetValue(qt_current_thread_data_tls_index, data); - data->threadId = reinterpret_cast(quintptr(GetCurrentThreadId())); + data->threadId.store(reinterpret_cast(quintptr(GetCurrentThreadId()))); QThread::setTerminationEnabled(false); -- cgit v1.2.3