NNTP-Posting-Date: Sun, 17 Apr 2011 15:35:13 -0500 Newsgroups: comp.lang.java.programmer,comp.lang.c++ Subject: Re: What's the deal with deadlocks From: Paavo Helde References: <23020668-d86c-489a-988b-7b379f34851c@j13g2000pro.googlegroups.com> Organization: PerkinElmer Inc Message-ID: User-Agent: Xnews/5.04.25 Date: Sun, 17 Apr 2011 15:35:13 -0500 Lines: 28 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-4gU1EjNDNGdIm+hoVaeNmgN1mWz98zIU+ww9Cwthb7EoAdbqgl6G20pBdmbKWKFkxfup2XVDnk5lrgl!/lo8OsqkSaC3OJl6/heIZMEvQfbj7AfHxmYos06Rkfyw3RNc4/31y4fP0pFG2P76JKfJQV+lVHq7!tDQIIlSH X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2217 Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!news.giganews.com.POSTED!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3091 comp.lang.c++:3886 Joe Snodgrass wrote in news:23020668-d86c-489a-988b- 7b379f34851c@j13g2000pro.googlegroups.com: > > The general concept is simple enough, but it seems to me that you'll > need special tools to diagnose this specific problem. How do you get > the debugger to look inside threads, see that they're hung, and find > out where the problem is happening? Do the debuggers have some > features that I haven't heard of? TIA. Debugging deadlocks is easier than e.g. race conditions, because when a deadlock appears the program is effectively stopped at the point of the error and one can easily attach the debugger and study the stack traces of all the threads. All the debuggers I use support this. The only problem is that if there are many threads running then finding the actual culprit may become tedious. I am not sure if this can be automated by some tools currently. For avoiding deadlocks in advance one can use valgrind+helgrind and fix all inconsistent lock order diagnostics it spits out. This way one should be able to get rid of all potential deadlock scenarios in all code paths covered by the test run. hth Paavo