PDA

View Full Version : Detect conflicting thread



giusepped
13th October 2009, 02:02
Hi all.
After reaching more than 20k lines of codes I am messing up with a problem very strange.
If I run my program, in very particular situations (depending on the speed of typing input text and hitting the Enter key) the UI freezes, like stayng in a loop.
On the other hand, if I wait a while, before hitting the Enter key, in most of cases the UI does not freeze.
I can guess which class "disturb", because if I do not use it, everything is ok. (For instance the class uses a QTimer).
There is way to detect which class are conflicting at runtime, or which threads? (in linux).
Thank you.

high_flyer
14th October 2009, 20:34
Debugging threads is one of the hardest things.
The fact you change something (like taking that class out) doesn't necessarily mean the problem has to do with that class, it simply means, that the application behavior is changed and thus the the dead-lock (it seems) doesn't appear any more, at least not with the same characteristics (maybe it will freeze but much later?).
You could just as well run the original code on a different machine, and a different behavior might be observer as well.

What you are describing sounds very much like a dead lock.

You have to make sure, that all the mutual used code between threads is guarded by mutexes semaphores or any similar mechanism - that would be the first step.

It is virtually impossible to help you more with out seeing the code, but 20k lines of code is really a problem.

How large is the code that has to do with the threads?
If its not too much, may be you can post it, and it will help us help you.

giusepped
15th October 2009, 02:16
I explained myself in an uncorrect way.
My application is just one big thread ( I used mistakenly the word thread).
Fortunately, I figured out what what the problem. A while condition which in some special cases does not exit.
Practically, if I type the input so fast, it could happen that non data were available to the while loop in order to exit.
Any way, thank you.
G