diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-12 08:25:41 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-12 09:08:31 (GMT) |
commit | d32127afb9b1ec49d4dc5cc672eaea11ebe56b72 (patch) | |
tree | c772cbbe80ca597ee845dd3998b3ab890116eaba | |
parent | 2ccc1336cbcb359e6dc1f4c482d8a188e8dcffb7 (diff) | |
download | Qt-d32127afb9b1ec49d4dc5cc672eaea11ebe56b72.zip Qt-d32127afb9b1ec49d4dc5cc672eaea11ebe56b72.tar.gz Qt-d32127afb9b1ec49d4dc5cc672eaea11ebe56b72.tar.bz2 |
QCoreApplication::library path, ensure mutex lock ordering
Do not keep the libraryPathMutex locked while calling QFactoryLoader::refreshAll
QFactoryLoader also lock a mutex, and recurse into QCoreApplication::libraryPath
Reviewed-by: Brad
Helgrind warning for reference:
==8442== Thread #1: lock order "0xDEBA470 before 0xDF63600" violated
==8442== at 0x4C2911E: QMutex::lock() (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==8442== by 0x7EE5870: QMutexLocker::QMutexLocker(QMutex*) (qmutex.h:102)
==8442== by 0x8025A8E: QCoreApplication::libraryPaths() (qcoreapplication.cpp:2234)
==8442== by 0x8006FDC: QFactoryLoader::update() (qfactoryloader.cpp:109)
==8442== by 0x8006F32: QFactoryLoader::QFactoryLoader(char const*, QString const&, Qt::CaseSensitivity) (qfactoryloader.cpp:99)
==8442== by 0x6DE4351: qt_guiPlatformPlugin() (qguiplatformplugin.cpp:101)
==8442== by 0x6DE7A5B: QApplicationPrivate::x11_apply_settings() (qapplication_x11.cpp:934)
==8442== by 0x6DE9BAD: qt_set_x11_resources(char const*, char const*, char const*, char const*) (qapplication_x11.cpp:1111)
==8442== by 0x6DF0CB3: qt_init(QApplicationPrivate*, int, _XDisplay*, unsigned long, unsigned long) (qapplication_x11.cpp:2323)
==8442== by 0x6D4EF4D: QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) (qapplication.cpp:793)
==8442== by 0x6D4EABE: QApplication::QApplication(int&, char**, int) (qapplication.cpp:712)
==8442== by 0x41350F: main (tst_examples.cpp:227)
==8442== Required order was established by acquisition of lock at 0xDEBA470
==8442== at 0x4C2911E: QMutex::lock() (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==8442== by 0x7EE5870: QMutexLocker::QMutexLocker(QMutex*) (qmutex.h:102)
==8442== by 0x8025FC3: QCoreApplication::addLibraryPath(QString const&) (qcoreapplication.cpp:2335)
==8442== by 0x6DE792D: QApplicationPrivate::x11_apply_settings() (qapplication_x11.cpp:927)
==8442== by 0x6DE9BAD: qt_set_x11_resources(char const*, char const*, char const*, char const*) (qapplication_x11.cpp:1111)
==8442== by 0x6DF0CB3: qt_init(QApplicationPrivate*, int, _XDisplay*, unsigned long, unsigned long) (qapplication_x11.cpp:2323)
==8442== by 0x6D4EF4D: QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) (qapplication.cpp:793)
==8442== by 0x6D4EABE: QApplication::QApplication(int&, char**, int) (qapplication.cpp:712)
==8442== by 0x41350F: main (tst_examples.cpp:227)
==8442== followed by a later acquisition of lock at 0xDF63600
==8442== at 0x4C2911E: QMutex::lock() (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==8442== by 0x7EE5870: QMutexLocker::QMutexLocker(QMutex*) (qmutex.h:102)
==8442== by 0x80086A9: QFactoryLoader::refreshAll() (qfactoryloader.cpp:249)
==8442== by 0x802607E: QCoreApplication::addLibraryPath(QString const&) (qcoreapplication.cpp:2344)
==8442== by 0x6DE792D: QApplicationPrivate::x11_apply_settings() (qapplication_x11.cpp:927)
==8442== by 0x6DE9BAD: qt_set_x11_resources(char const*, char const*, char const*, char const*) (qapplication_x11.cpp:1111)
==8442== by 0x6DF0CB3: qt_init(QApplicationPrivate*, int, _XDisplay*, unsigned long, unsigned long) (qapplication_x11.cpp:2323)
==8442== by 0x6D4EF4D: QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) (qapplication.cpp:793)
==8442== by 0x6D4EABE: QApplication::QApplication(int&, char**, int) (qapplication.cpp:712)
==8442== by 0x41350F: main (tst_examples.cpp:227)a
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0a5e06e..512e193 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2308,6 +2308,7 @@ void QCoreApplication::setLibraryPaths(const QStringList &paths) if (!coreappdata()->app_libpaths) coreappdata()->app_libpaths = new QStringList; *(coreappdata()->app_libpaths) = paths; + locker.unlock(); QFactoryLoader::refreshAll(); } @@ -2341,6 +2342,7 @@ void QCoreApplication::addLibraryPath(const QString &path) if (!canonicalPath.isEmpty() && !coreappdata()->app_libpaths->contains(canonicalPath)) { coreappdata()->app_libpaths->prepend(canonicalPath); + locker.unlock(); QFactoryLoader::refreshAll(); } } |