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

List:       kde-commits
Subject:    Re: [kdelibs/KDE/4.7] kio/kio: Fix crash in QThreadPrivate::finish
From:       Dawit A <adawit () kde ! org>
Date:       2011-08-08 14:18:02
Message-ID: CALa28R4crJJ0s8cGnVGi4+kzUjj9xV4Ef=KWcjZ_zPMBS46pwg () mail ! gmail ! com
[Download RAW message or body]

Dunno why I did not think of this :) However there is one issue with
this. For those with slow DNS, waiting for the thread termination to
finish is akin to waiting for the slow DNS server beyond the timeout
duration specified. IOW, it is the same as doing QHostInfo::lookupHost
directly. Though I try to avoid local event loops as much as possible,
would not the solution I proposed in
https://git.reviewboard.kde.org/r/102238/ have been better than simply
doing this ?

On Mon, Aug 8, 2011 at 9:00 AM, David Faure <faure@kde.org> wrote:
> 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