[Qt-interest] QMutex deadlock without using QMutex

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Wed Apr 28 02:20:45 CEST 2010


> -----Original Message-----
> Hi,
> 
> I am running into a weird problem.
> For running calculations on a large dataset, I split up the 
> work over a 
> number of threads. I use signals and slots to communicate between the 
> worker threads and a coordinator thread, and also between that 
> coordinator thread and the rest of the application. I do not use any 
> explicit thread synchronisation methods like QMutex in that 
> part of the 
> application.
> 
> Still, I get this error in my output:
> QMutex::lock: Deadlock detected in thread <some number>
> 
> What could this mean? Are there other causes conceivable for this 
> happening? Is there behind-the-scenes locking/unlocking of 
> mutexes that 
> Qt is doing when performing signalling between threads?
> 
> André

Hi André, 

Are you connecting to slots on the thread objects themselves (bad), or to
objects created in the thread's run method (good)?  Check the thread
affinities of the objects you are connecting to.  You might find some that
are the same, which means Qt will not queue the signals, but call direct.  

Also when the manager thread gets a worker finished signal, instead of
signalling the response immediately, try a single-shot timer with 0 delay.
That way, the first signal has completely finished, when you send the
response signal.  

Hope that helps, 

Tony.





More information about the Qt-interest-old mailing list