Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.java.programmer,comp.lang.c++ Subject: Re: What's the deal with deadlocks Date: Mon, 18 Apr 2011 08:41:14 +1200 Lines: 28 Message-ID: <9111jaFpdmU7@mid.individual.net> References: <23020668-d86c-489a-988b-7b379f34851c@j13g2000pro.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 3y368MfB3L7ev0r/vuCK/gLcAah3Guno8eO4pOLkD0S8e+c3LU Cancel-Lock: sha1:Go+VcCxMPaLsTFhXji5wMqrWygs= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3092 comp.lang.c++:3887 On 04/18/11 08:35 AM, Paavo Helde wrote: > 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. There are also static deadlock analysis tools such as Sun Studio's LockLint. -- Ian Collins