Bug 75944

Summary: Kget crashes on Redhat 9 with NPTL
Product: [Applications] kget Reporter: Christoph Bartoschek <bartoschek>
Component: generalAssignee: KGet authors <kget>
Status: RESOLVED DUPLICATE    
Severity: normal CC: rdieter
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: First step solution
patch for Thread !

Description Christoph Bartoschek 2004-02-23 21:50:35 UTC
Version:            (using KDE KDE 3.2.0)
Installed from:    Compiled From Sources
Compiler:          gcc 3.4 prerelease and gcc 3.3.2 
OS:          Linux

Kget does not work on my machine with RedHat 9. It does not crash in the strong sense, but it hangs forever in a call to QThread::wait(). This behavoiur is not deterministic. Sometimes it hangs after the first download, sometimes during the second, but at least before the fifth one it hangs.

This results from a IMHO unappropriate use of a condition variable, QThread::terminate() and QThread::wait(). The patch in the next message solves the problem. The patch was made against the actual CVS KDE_3_2_BRANCH.

Kget hangs because QThread::terminate() is called and the thread does not reach a cancellable state. The patch is a first step to a correct solution. Because it waits on the mutex for new jobs, the thread can be cancelled by QThread::terminate().

Some additional remarks:

- QWaitCondition::wait(int) should not be used.
- QThread::terminate() should not be used at all. A better solution would be to define a TERMINATE Slavecommand. The slave exits Slave::run() when this command is emitted. I could not find out how Slave::slotResult is called and which thread is responsible for what, but I think Slave::slotResult is the appropriate Place to send such a command to the Slave.
- Is there a design document which explains how threads are used in kget? After looking only at slave.h, slave.cpp and transfer.cpp a little bit, it seems that threads are not necessary at all.
Comment 1 Christoph Bartoschek 2004-02-23 21:52:13 UTC
Created attachment 4860 [details]
First step solution

This bug is not a normal bug is a crash.
Comment 2 Christoph Bartoschek 2004-02-23 22:05:07 UTC
Maybe this bug is a duplicate of a lot of other hang, crash bugs.
Especially it uses another solution to the problem than Thomas Zell in
Bug #74597
Comment 3 i.linty 2004-03-01 12:17:24 UTC
Created attachment 4956 [details]
patch for Thread !

This patch probably correct your this bug ! Can You test it ?
Bye
Comment 4 Rex Dieter 2004-03-01 16:54:33 UTC
I can confirm that I've periodically seen KGet get hung up on RedHat 9.  I'll go ahead and mark it as a dup of 74597 as well.

*** This bug has been marked as a duplicate of 74597 ***