[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdelibs/KDE/4.7] kio/kio: Fix crash in QThreadPrivate::finish due
From:       David Faure <faure () kde ! org>
Date:       2011-08-08 13:00:54
Message-ID: 20110808130054.49531A60A6 () git ! kde ! org
[Download RAW message or body]

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();
     }
 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic