Hello community, here is the log from the commit of package libqt5-qtbase for openSUSE:Factory checked in at 2020-07-09 13:15:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libqt5-qtbase (Old) and /work/SRC/openSUSE:Factory/.libqt5-qtbase.new.3060 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libqt5-qtbase" Thu Jul 9 13:15:56 2020 rev:108 rq:818846 version:5.15.0 Changes: -------- --- /work/SRC/openSUSE:Factory/libqt5-qtbase/libqt5-qtbase.changes 2020-06-11 14:47:40.797903022 +0200 +++ /work/SRC/openSUSE:Factory/.libqt5-qtbase.new.3060/libqt5-qtbase.changes 2020-07-09 13:16:04.252644447 +0200 @@ -1,0 +2,6 @@ +Sun Jul 5 10:16:48 UTC 2020 - Fabian Vogt <[email protected]> + +- Add patch to prevent stuck image conversion (boo#1172599, QTBUG-84619): + * 0001-Do-not-multithread-if-already-in-a-global-threadpool.patch + +------------------------------------------------------------------- New: ---- 0001-Do-not-multithread-if-already-in-a-global-threadpool.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libqt5-qtbase.spec ++++++ --- /var/tmp/diff_new_pack.0X9yYl/_old 2020-07-09 13:16:06.348651072 +0200 +++ /var/tmp/diff_new_pack.0X9yYl/_new 2020-07-09 13:16:06.352651084 +0200 @@ -67,6 +67,7 @@ Patch21: 0001-Don-t-white-list-recent-Mesa-versions-for-multithrea.patch Patch24: fix-fixqt4headers.patch # patches 1000-2000 and above from upstream 5.15 branch # +Patch1000: 0001-Do-not-multithread-if-already-in-a-global-threadpool.patch # patches 2000-3000 and above from upstream qt6/dev branch # # Not accepted yet, https://codereview.qt-project.org/c/qt/qtbase/+/255384 Patch2001: 0002-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch ++++++ 0001-Do-not-multithread-if-already-in-a-global-threadpool.patch ++++++ >From 5801eb483cce1a9c459b3e86d57dc6fe6f643480 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <[email protected]> Date: Tue, 2 Jun 2020 10:59:21 +0200 Subject: [PATCH] Do not multithread if already in a global threadpool thread This can lead to a deadlock if we block all the worker threads, waiting for the worker threads to finish. Fixes: QTBUG-84619 Change-Id: I92b7f96007897d86ece0c34223bab0df4ccbed9a Reviewed-by: Sona Kurazyan <[email protected]> (cherry picked from commit 87d32424de2f471a520c1f3ba0c3035fbff7ee06) Reviewed-by: Qt Cherry-pick Bot <[email protected]> --- src/corelib/thread/qthreadpool.cpp | 24 ++++++++++++++++++++++++ src/corelib/thread/qthreadpool.h | 2 ++ src/gui/image/qimage.cpp | 7 ++++--- src/gui/image/qimage_conversions.cpp | 15 +++++++++------ src/gui/painting/qimagescale.cpp | 5 +++-- src/gui/painting/qimagescale_neon.cpp | 5 +++-- src/gui/painting/qimagescale_sse4.cpp | 5 +++-- 7 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 44cdf071df..a583298f01 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -52,6 +52,7 @@ Q_GLOBAL_STATIC(QThreadPool, theInstance) */ class QThreadPoolThread : public QThread { + Q_OBJECT public: QThreadPoolThread(QThreadPoolPrivate *manager); void run() override; @@ -745,6 +746,28 @@ void QThreadPool::clear() d->clear(); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +/*! + \internal + + Returns \c true if \a thread is a thread managed by this thread pool. +*/ +#else +/*! + \since 6.0 + + Returns \c true if \a thread is a thread managed by this thread pool. +*/ +#endif +bool QThreadPool::contains(const QThread *thread) const +{ + Q_D(const QThreadPool); + const QThreadPoolThread *poolThread = qobject_cast<const QThreadPoolThread *>(thread); + if (!poolThread) + return false; + return d->allThreads.contains(const_cast<QThreadPoolThread *>(poolThread)); +} + #if QT_DEPRECATED_SINCE(5, 9) /*! \since 5.5 @@ -766,3 +789,4 @@ void QThreadPool::cancel(QRunnable *runnable) QT_END_NAMESPACE #include "moc_qthreadpool.cpp" +#include "qthreadpool.moc" diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h index e3691ab010..004f76a240 100644 --- a/src/corelib/thread/qthreadpool.h +++ b/src/corelib/thread/qthreadpool.h @@ -93,6 +93,8 @@ public: void clear(); + bool contains(const QThread *thread) const; + #if QT_DEPRECATED_SINCE(5, 9) QT_DEPRECATED_X("use tryTake(), but note the different deletion rules") void cancel(QRunnable *runnable); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 2646d298e9..17c31cd8ae 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -5047,15 +5047,16 @@ void QImage::applyColorTransform(const QColorTransform &transform) }; } -#if QT_CONFIG(thread) +#if QT_CONFIG(thread) && !defined(Q_OS_WASM) int segments = sizeInBytes() / (1<<16); segments = std::min(segments, height()); - if (segments > 1) { + QThreadPool *threadPool = QThreadPool::globalInstance(); + if (segments > 1 && !threadPool->contains(QThread::currentThread())) { QSemaphore semaphore; int y = 0; for (int i = 0; i < segments; ++i) { int yn = (height() - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { + threadPool->start([&, y, yn]() { transformSegment(y, y + yn); semaphore.release(1); }); diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 506ebc797f..cbfdbdeadb 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -236,14 +236,15 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio int segments = src->nbytes / (1<<16); segments = std::min(segments, src->height); - if (segments <= 1) + QThreadPool *threadPool = QThreadPool::globalInstance(); + if (segments <= 1 || threadPool->contains(QThread::currentThread())) return convertSegment(0, src->height); QSemaphore semaphore; int y = 0; for (int i = 0; i < segments; ++i) { int yn = (src->height - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { + threadPool->start([&, y, yn]() { convertSegment(y, y + yn); semaphore.release(1); }); @@ -290,14 +291,15 @@ void convert_generic_to_rgb64(QImageData *dest, const QImageData *src, Qt::Image int segments = src->nbytes / (1<<16); segments = std::min(segments, src->height); - if (segments <= 1) + QThreadPool *threadPool = QThreadPool::globalInstance(); + if (segments <= 1 || threadPool->contains(QThread::currentThread())) return convertSegment(0, src->height); QSemaphore semaphore; int y = 0; for (int i = 0; i < segments; ++i) { int yn = (src->height - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { + threadPool->start([&, y, yn]() { convertSegment(y, y + yn); semaphore.release(1); }); @@ -396,12 +398,13 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im #ifdef QT_USE_THREAD_PARALLEL_IMAGE_CONVERSIONS int segments = data->nbytes / (1<<16); segments = std::min(segments, data->height); - if (segments > 1) { + QThreadPool *threadPool = QThreadPool::globalInstance(); + if (segments > 1 && !threadPool->contains(QThread::currentThread())) { QSemaphore semaphore; int y = 0; for (int i = 0; i < segments; ++i) { int yn = (data->height - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { + threadPool->start([&, y, yn]() { convertSegment(y, y + yn); semaphore.release(1); }); diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp index 2395c891ce..aac1e20f7b 100644 --- a/src/gui/painting/qimagescale.cpp +++ b/src/gui/painting/qimagescale.cpp @@ -307,12 +307,13 @@ static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, con #if QT_CONFIG(thread) && !defined(Q_OS_WASM) int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); segments = std::min(segments, dh); - if (segments > 1) { + QThreadPool *threadPool = QThreadPool::globalInstance(); + if (segments > 1 && !threadPool->contains(QThread::currentThread())) { QSemaphore semaphore; int y = 0; for (int i = 0; i < segments; ++i) { int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { + threadPool->start([&, y, yn]() { scaleSection(y, y + yn); semaphore.release(1); }); diff --git a/src/gui/painting/qimagescale_neon.cpp b/src/gui/painting/qimagescale_neon.cpp index 65fe3fac3c..046e56b419 100644 --- a/src/gui/painting/qimagescale_neon.cpp +++ b/src/gui/painting/qimagescale_neon.cpp @@ -58,12 +58,13 @@ static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, con #if QT_CONFIG(thread) && !defined(Q_OS_WASM) int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); segments = std::min(segments, dh); - if (segments > 1) { + QThreadPool *threadPool = QThreadPool::globalInstance(); + if (segments > 1 && !threadPool->contains(QThread::currentThread())) { QSemaphore semaphore; int y = 0; for (int i = 0; i < segments; ++i) { int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { + threadPool->start([&, y, yn]() { scaleSection(y, y + yn); semaphore.release(1); }); diff --git a/src/gui/painting/qimagescale_sse4.cpp b/src/gui/painting/qimagescale_sse4.cpp index 1760e72f65..70cfa08d95 100644 --- a/src/gui/painting/qimagescale_sse4.cpp +++ b/src/gui/painting/qimagescale_sse4.cpp @@ -59,12 +59,13 @@ static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, con #if QT_CONFIG(thread) && !defined(Q_OS_WASM) int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); segments = std::min(segments, dh); - if (segments > 1) { + QThreadPool *threadPool = QThreadPool::globalInstance(); + if (segments > 1 && !threadPool->contains(QThread::currentThread())) { QSemaphore semaphore; int y = 0; for (int i = 0; i < segments; ++i) { int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { + threadPool->start([&, y, yn]() { scaleSection(y, y + yn); semaphore.release(1); }); -- 2.25.1
