summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qlibrary.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-04-02 12:08:41 -0300
committerThiago Macieira <thiago.macieira@intel.com>2020-04-06 13:27:05 +0000
commit276fa8383a7535765be7182883ef4aade17ce013 (patch)
tree46ee05335c117293da8f1b712b4b4d0e22d7c7d6 /src/corelib/plugin/qlibrary.cpp
parent615204e0762c2e12077e8c8dd3c6d29b9648f163 (diff)
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>
Diffstat (limited to 'src/corelib/plugin/qlibrary.cpp')
-rw-r--r--src/corelib/plugin/qlibrary.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index ddb053c26f..be9d92b204 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;