commit:     2de10f7d7c0c213d01dcbf2b063105c4a0b033e7
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 27 08:57:33 2022 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Wed Jul 27 08:57:58 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2de10f7d

dev-qt/qtconcurrent: QtConcurrent::ReduceKernel: fix race conditions

Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 dev-qt/qtconcurrent/Manifest                       |  1 +
 .../qtconcurrent-5.15.5-fix-race-conditions.patch  | 41 ++++++++++++++++++++++
 dev-qt/qtconcurrent/qtconcurrent-5.15.5-r1.ebuild  | 25 +++++++++++++
 3 files changed, 67 insertions(+)

diff --git a/dev-qt/qtconcurrent/Manifest b/dev-qt/qtconcurrent/Manifest
index 9f98cfd5161e..9667a62512b5 100644
--- a/dev-qt/qtconcurrent/Manifest
+++ b/dev-qt/qtconcurrent/Manifest
@@ -1,3 +1,4 @@
 DIST qtbase-5.15-gentoo-patchset-1.tar.xz 4204 BLAKE2B 
1399eb6f4c776d370e1837351a72b604440658a3a2d1bd0c725b9ef149b09d236347f5f4b37f652c33310048a0a7df54e24453b404dc45507fd4f7c5fdf144cd
 SHA512 
c857fc746bacb047321cdb762f3c7c48ce2a0d24045a9e708edd38532568dbbc74e9e971425a72a3c2a5ca0662b3e6333831f6c1b7746525b99d46000b63111f
 DIST qtbase-5.15.5-gentoo-kde-1.tar.xz 520224 BLAKE2B 
48807bc79cede557b114786ee072d8d94545f4ada3d96aa4fe04dbf79a356dc6c17d9299014ed70aa10296346c30c7512fb7d9f88ee4b301e9a54a241363be8b
 SHA512 
ab9f27d506d7aa1a9339ba52d51daffb4c6f9abb5d858fd728ef2110528bc0f2ae101b4e2e7c344836b42e4aafa2c5a4ab5c5fa37465e692cce500c0f3347fa7
+DIST qtbase-5.15.5-gentoo-kde-2.tar.xz 526240 BLAKE2B 
68ecca0805c2ea0b29b65706b0c03a3ead1d106e089f2a48a988035842d0cc8ac67d950cbc67ae8f8be860fd11443579d3e06bfe96a2e3161f94e07206d2815e
 SHA512 
d877a2eb4cd05b712a7db6a943f955d3ced88f51efe3e29b2d6716fba4da08398dbd2ed580ca5b9bfbd92a5a20e34451e06a324274447d4b3692b25af4ff8ddf
 DIST qtbase-everywhere-opensource-src-5.15.5.tar.xz 50247388 BLAKE2B 
e9bbfe8e73e6f25ccadeef722818b5aeb82d1f136bec21fcbc3b26bf76044b38f25c7268010c648e1161e9b61013b8b775f17b9fdcfdd70402bdfbf70bf7f9d5
 SHA512 
ce80eedc88abbd5a200bacc10a8e94adc1ef2122ac220715ba084adf1e32d67f2dc66168503de5fb5b5a6ab15f7a75ca23dc9956aed12ead994a8ffa6291ef87

diff --git 
a/dev-qt/qtconcurrent/files/qtconcurrent-5.15.5-fix-race-conditions.patch 
b/dev-qt/qtconcurrent/files/qtconcurrent-5.15.5-fix-race-conditions.patch
new file mode 100644
index 000000000000..c16da19a507d
--- /dev/null
+++ b/dev-qt/qtconcurrent/files/qtconcurrent-5.15.5-fix-race-conditions.patch
@@ -0,0 +1,41 @@
+From 33ed9a414da190ffa8099856901df792ff9150d5 Mon Sep 17 00:00:00 2001
+From: Sona Kurazyan <[email protected]>
+Date: Mon, 18 Jul 2022 14:46:24 +0200
+Subject: [PATCH] QtConcurrent::ReduceKernel: fix race conditions
+
+resultsMapSize is modified inside the runReduce() method, and the
+writes are protected via mutex lock. However, reads of resultsMapSize
+through shouldThrottle()/shouldStartThread() (that can be called by
+multiple threads) are done without a lock. Added the missing locks.
+
+Task-number: QTBUG-104787
+Pick-to: 6.4 6.3 6.2 5.15
+Change-Id: I700e7b66e67025bc7f570bc8ad69409b82675049
+Reviewed-by: Jarek Kobus <[email protected]>
+Reviewed-by: Marc Mutz <[email protected]>
+(cherry picked from commit 7afb093dd77f0ed9a1b4145d2d279810aba411c7)
+---
+ src/concurrent/qtconcurrentreducekernel.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/concurrent/qtconcurrentreducekernel.h 
b/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/src/concurrent/qtconcurrentreducekernel.h
++++ b/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+-- 
+GitLab
+

diff --git a/dev-qt/qtconcurrent/qtconcurrent-5.15.5-r1.ebuild 
b/dev-qt/qtconcurrent/qtconcurrent-5.15.5-r1.ebuild
new file mode 100644
index 000000000000..7b32aa70d089
--- /dev/null
+++ b/dev-qt/qtconcurrent/qtconcurrent-5.15.5-r1.ebuild
@@ -0,0 +1,25 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+QT5_KDEPATCHSET_REV=2
+QT5_MODULE="qtbase"
+inherit qt5-build
+
+DESCRIPTION="Multi-threading concurrence support library for the Qt5 framework"
+
+if [[ ${QT5_BUILD_TYPE} == release ]]; then
+       KEYWORDS="amd64 arm arm64 ~hppa ~loong ppc ppc64 ~riscv ~sparc x86"
+fi
+
+IUSE=""
+
+DEPEND="=dev-qt/qtcore-${QT5_PV}*:5="
+RDEPEND="${DEPEND}"
+
+QT5_TARGET_SUBDIRS=(
+       src/concurrent
+)
+
+PATCHES=( "${FILESDIR}/${P}-fix-race-conditions.patch" ) # kde/5.15 branch

Reply via email to