- How to find which thread is in infinite loop?
- Posted by glchin@hotmail.com on June 3rd, 2007
I inherited a VC++ application that has a large number of threads.
Once in a while, the CPU utilization on my XP workstation reaches
100%, indicating that at least one thread in the app has hit an
infinite loop. Since the problem doesn't occur consistently, I was
thinking about finding the ID of the affected thread with a utility
similar to Process Explorer. During each thread creation, I would
write the thread function and ID to a log file, helping me to find the
culprit.
Is this approach feasible? What is a good utility to use? I don't
wish to use the Visual Studio debugger since it alters the execution
speed of the app.
- Posted by Bertel Brander on June 3rd, 2007
glchin@hotmail.com skrev:
You could try GetThreadTimes:
http://msdn2.microsoft.com/en-us/library/ms683237.aspx
You could spawn yet another thread and call GetThreadTimes
from that thread, every now and then.
--
Just another homepage:
http://damb.dk
But it's mine - Bertel
- Posted by Stephen Kellett on June 4th, 2007
In message <1180903928.301398.230010@k79g2000hse.googlegroups .com>,
glchin@hotmail.com writes
Free: Thread Status
http://www.objmedia.demon.co.uk/free...eadStatus.html
Commercial: Thread Validator
http://www.softwareverify.com/cpp/thread/index.html
Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
Reg Office: 24 Windmill Walk, Sutton, Ely, Cambs CB6 2NH.
- Posted by Barry on June 4th, 2007
<glchin@hotmail.com> wrote in message
news:1180903928.301398.230010@k79g2000hse.googlegr oups.com...
The best thing to do is notify the person you "inherited" the program
from and remove it from your computer.
- Posted by Ali on June 4th, 2007
On Jun 4, 4:52 am, glc...@hotmail.com wrote:
Well! folks do have good solution for you here
some seems obvious
and some are simply asking you to giveUp . l0l
BTW what is bad in logging/fileWrite/printf? atleast to fix the very
bug.
Or another way to do would be something like, i would create a
separate thread (say threadProb) that will just probe every thread
with its ID at predefined time intervals.
0) Create a vector/list to hold all the threads ID.
1) Add thread ID to your list when ever new thread is created.
Now your threadProb will also hang while probing the thread which is
in infinite loop. But ofcourse you need to log/writeFile in your
threadProb to figure out the bad guy.
ali