From kde-commits Mon Aug 08 13:00:54 2011 From: David Faure Date: Mon, 08 Aug 2011 13:00:54 +0000 To: kde-commits Subject: [kdelibs/KDE/4.7] kio/kio: Fix crash in QThreadPrivate::finish due Message-Id: <20110808130054.49531A60A6 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=131280848820957 Git commit b4c42a6bb534933fac2301fc8c0d3a81dd09b303 by David Faure. Committed on 08/08/2011 at 14:56. Pushed by dfaure into branch 'KDE/4.7'. Fix crash in QThreadPrivate::finish due to terminate() without wait(). If the QThread is destroyed just after terminate() (which is non-blocking), there's a possibility that the pthread callback (QThreadPrivate::finish) is called after the QThread is deleted - so it will use deleted data. In short: you must wait() after terminate(), and before deleting the QThread. M +1 -0 kio/kio/hostinfo.cpp http://commits.kde.org/kdelibs/b4c42a6bb534933fac2301fc8c0d3a81dd09b303 diff --git a/kio/kio/hostinfo.cpp b/kio/kio/hostinfo.cpp index 251c283..344b1d8 100644 --- a/kio/kio/hostinfo.cpp +++ b/kio/kio/hostinfo.cpp @@ -190,6 +190,7 @@ QHostInfo HostInfo::lookupHost(const QString& hostName, unsigned long timeout) if (!lookupThread.wait(timeout)) { kDebug() << "Name look up for" << hostName << "failed"; lookupThread.terminate(); + lookupThread.wait(); return QHostInfo(); }