From cd3e2588e672a9ceea0c165a84bcd2ab89ab708f Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 20 Aug 2018 15:29:05 +0200 Subject: Fix race condition when removing worker scripts As reported by TSAN, while registering new workers is done in the QML engine thread with the lock held, the removal of workers from the hash is done without a lock in the thread and therefore a data race. Change-Id: I932ed6127fe34b3b3da0b0202f42e877ae6e0d5f Reviewed-by: Michael Brasser Reviewed-by: Lars Knoll --- src/qml/types/qquickworkerscript.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/qml/types/qquickworkerscript.cpp') diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 4fef0fab7c..f8616bf709 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -215,6 +215,7 @@ bool QQuickWorkerScriptEnginePrivate::event(QEvent *event) emit stopThread(); return true; } else if (event->type() == (QEvent::Type)WorkerRemoveEvent::WorkerRemove) { + QMutexLocker locker(&m_lock); WorkerRemoveEvent *workerEvent = static_cast(event); QHash::iterator itr = workers.find(workerEvent->workerId()); if (itr != workers.end()) { -- cgit v1.2.3