From: "Andreas Sturmlechner" <asturm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtcore/files/
Date: Thu, 9 Apr 2020 21:44:05 +0000 (UTC) [thread overview]
Message-ID: <1586468614.9c8bc45ef269f19e43aed9c361e7acb7504c3017.asturm@gentoo> (raw)
commit: 9c8bc45ef269f19e43aed9c361e7acb7504c3017
Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 7 18:22:15 2020 +0000
Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Thu Apr 9 21:43:34 2020 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9c8bc45e
dev-qt/qtcore: QLibrary: fix deadlock caused by fix to QTBUG-39642
See also: https://bugreports.qt.io/browse/QTBUG-83207
Package-Manager: Portage-2.3.96, Repoman-2.3.22
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
.../files/qtcore-5.14.2-QLibrary-deadlock.patch | 106 +++++++++++++++++++++
1 file changed, 106 insertions(+)
diff --git a/dev-qt/qtcore/files/qtcore-5.14.2-QLibrary-deadlock.patch b/dev-qt/qtcore/files/qtcore-5.14.2-QLibrary-deadlock.patch
new file mode 100644
index 00000000000..6a9c9921b7d
--- /dev/null
+++ b/dev-qt/qtcore/files/qtcore-5.14.2-QLibrary-deadlock.patch
@@ -0,0 +1,106 @@
+From 276fa8383a7535765be7182883ef4aade17ce013 Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Thu, 2 Apr 2020 12:08:41 -0300
+Subject: [PATCH] QLibrary: fix deadlock caused by fix to QTBUG-39642
+
+Commit ae6f73e8566fa76470937aca737141183929a5ec inserted a mutex around
+the entire load_sys(). We had reasoed that deadlocks would only occur if
+the object creation in instance() recursed into its own instance(),
+which was already a bug. But we had forgotten that dlopen()/
+LoadLibrary() executes initialization code from the module being loaded,
+which could cause a recursion back into the same QPluginLoader or
+QLibrary object. This recursion is benign because the module *is* loaded
+and dlopen()/LoadLibrary() returns the same handle.
+
+[ChangeLog][QtCore][QLibrary and QPluginLoader] Fixed a deadlock that
+would happen if the plugin or library being loaded has load-time
+initialization code (C++ global variables) that recursed back into the
+same QLibrary or QPluginLoader object.
+
+PS: QLibraryPrivate::loadPlugin() updates pluginState outside a mutex
+lock, so pluginState should be made an atomic variable. Once that is
+done, we'll only need locking the mutex to update errorString (no
+locking before loading).
+
+Fixes: QTBUG-83207
+Task-number: QTBUG-39642
+Change-Id: Ibdc95e9af7bd456a94ecfffd160209304e5ab2eb
+Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
+Reviewed-by: David Faure <david.faure@kdab.com>
+---
+ src/corelib/plugin/qlibrary.cpp | 2 --
+ src/corelib/plugin/qlibrary_unix.cpp | 4 ++++
+ src/corelib/plugin/qlibrary_win.cpp | 3 +++
+ 3 files changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
+index ddb053c26fa..be9d92b2048 100644
+--- a/src/corelib/plugin/qlibrary.cpp
++++ b/src/corelib/plugin/qlibrary.cpp
+@@ -576,9 +576,7 @@ bool QLibraryPrivate::load()
+
+ Q_TRACE(QLibraryPrivate_load_entry, fileName);
+
+- mutex.lock();
+ bool ret = load_sys();
+- mutex.unlock();
+ if (qt_debug_component()) {
+ if (ret) {
+ qDebug() << "loaded library" << fileName;
+diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
+index 017aa97b66a..a5c72f81d96 100644
+--- a/src/corelib/plugin/qlibrary_unix.cpp
++++ b/src/corelib/plugin/qlibrary_unix.cpp
+@@ -123,6 +123,7 @@ QStringList QLibraryPrivate::prefixes_sys()
+
+ bool QLibraryPrivate::load_sys()
+ {
++ QMutexLocker locker(&mutex);
+ QString attempt;
+ QFileSystemEntry fsEntry(fileName);
+
+@@ -213,6 +214,7 @@ bool QLibraryPrivate::load_sys()
+ }
+ #endif
+
++ locker.unlock();
+ bool retry = true;
+ Handle hnd = nullptr;
+ for (int prefix = 0; retry && !hnd && prefix < prefixes.size(); prefix++) {
+@@ -273,6 +275,8 @@ bool QLibraryPrivate::load_sys()
+ }
+ }
+ #endif
++
++ locker.relock();
+ if (!hnd) {
+ errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName, qdlerror());
+ }
+diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
+index 000bf762763..ef58724be8e 100644
+--- a/src/corelib/plugin/qlibrary_win.cpp
++++ b/src/corelib/plugin/qlibrary_win.cpp
+@@ -78,6 +78,7 @@ bool QLibraryPrivate::load_sys()
+ // fileName
+ //
+ // NB If it's a plugin we do not ever try the ".dll" extension
++ QMutexLocker locker(&mutex);
+ QStringList attempts;
+
+ if (pluginState != IsAPlugin)
+@@ -95,6 +96,7 @@ bool QLibraryPrivate::load_sys()
+ attempts.prepend(QDir::rootPath() + fileName);
+ #endif
+
++ locker.unlock();
+ Handle hnd = nullptr;
+ for (const QString &attempt : qAsConst(attempts)) {
+ #ifndef Q_OS_WINRT
+@@ -115,6 +117,7 @@ bool QLibraryPrivate::load_sys()
+ #ifndef Q_OS_WINRT
+ SetErrorMode(oldmode);
+ #endif
++ locker.relock();
+ if (!hnd) {
+ errorString = QLibrary::tr("Cannot load library %1: %2").arg(
+ QDir::toNativeSeparators(fileName), qt_error_string());
next reply other threads:[~2020-04-09 21:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-09 21:44 Andreas Sturmlechner [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-02-05 22:37 [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtcore/files/ Andreas Sturmlechner
2022-12-10 12:25 Andreas Sturmlechner
2022-04-18 7:15 Sam James
2018-05-13 6:56 Andreas Sturmlechner
2017-12-28 10:03 Michael Palimaka
2016-04-16 17:18 Davide Pesavento
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1586468614.9c8bc45ef269f19e43aed9c361e7acb7504c3017.asturm@gentoo \
--to=asturm@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox