Details
Description
After upgrading from Qt 4.5 i am getting deadlock in QSettings::getPath()
I have added debug function (qsettings_debug.patch) and run it in gdb:
Breakpoint 1, 0xb598918c in printDeadlock() () from /opt/qtmoko/lib/libQtCore.so.4
(gdb) bt
#0 0xb598918c in printDeadlock() () from /opt/qtmoko/lib/libQtCore.so.4
#1 0xb598a96c in getPath(QSettings::Format, QSettings::Scope) () from /opt/qtmoko/lib/libQtCore.so.4
#2 0xb5991bb0 in QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format, QSettings::Scope, QString const&, QString const&) () from /opt/qtmoko/lib/libQtCore.so.4
#3 0xb5991fb0 in QSettings::QSettings(QSettings::Scope, QString const&, QString const&, QObject*) ()
from /opt/qtmoko/lib/libQtCore.so.4
#4 0xb59b1fb8 in QFactoryLoader::update() () from /opt/qtmoko/lib/libQtCore.so.4
#5 0xb59b4004 in QFactoryLoader::QFactoryLoader(char const*, QString const&, Qt::CaseSensitivity) ()
from /opt/qtmoko/lib/libQtCore.so.4
#6 0xb59fed14 in loader() () from /opt/qtmoko/lib/libQtCore.so.4
#7 0xb5a01640 in QTextCodec::codecForName(QByteArray const&) () from /opt/qtmoko/lib/libQtCore.so.4
#8 0xb5a0282c in QTextCodec::codecForName(char const*) () from /opt/qtmoko/lib/libQtCore.so.4
#9 0xb59ff620 in setupLocaleMapper() () from /opt/qtmoko/lib/libQtCore.so.4
#10 0xb5a003a4 in QTextCodec::codecForLocale() () from /opt/qtmoko/lib/libQtCore.so.4
#11 0xb591776c in QString::fromLocal8Bit(char const*, int) () from /opt/qtmoko/lib/libQtCore.so.4
#12 0xb5951dc8 in locale_decode(QByteArray const&) () from /opt/qtmoko/lib/libQtCore.so.4
#13 0xb5951be4 in QFile::decodeName(QByteArray const&) () from /opt/qtmoko/lib/libQtCore.so.4
#14 0xb59a33d0 in QFSFileEngine::homePath() () from /opt/qtmoko/lib/libQtCore.so.4
#15 0xb59492fc in QDir::homePath() () from /opt/qtmoko/lib/libQtCore.so.4
#16 0xb598a5e8 in initDefaultPaths(QMutexLocker*) () from /opt/qtmoko/lib/libQtCore.so.4
#17 0xb598a8cc in getPath(QSettings::Format, QSettings::Scope) () from /opt/qtmoko/lib/libQtCore.so.4
#18 0xb5991bb0 in QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format, QSettings::Scope, QString const&, QString const&) () from /opt/qtmoko/lib/libQtCore.so.4
#19 0xb59920a0 in QSettings::QSettings(QString const&, QString const&, QObject*) () from /opt/qtmoko/lib/libQtCore.so.4
#20 0xb698f6d4 in ?? () from /opt/qtmoko/lib/libqtopia.so.4
Cannot access memory at address 0x0
#21 0xb698f6d4 in ?? () from /opt/qtmoko/lib/libqtopia.so.4
Cannot access memory at address 0x0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
You can see this recursion that is causing the deadlock:
getPath()>initDefaultPaths()>QDir::homePath()>...>QSettings::QSettings()->getPath()
This first call to getPath() locks the globalMutex and second getPath() call causes deadlock.
This bug is probably not triggered on X11-QT because of different initialization order.
Btw the bug is also affecting other QtEmbedded projects - i have found e.g. this reference http://osdir.com/ml/marble-devel/2012-05/msg00129.html
The second attached patch should fix this bug.