Tiburon Preview: Vista Wait Chain Traversal
I see that several of my co-workers have started blogging about new features in Tiburon, the upcoming release of Delphi and C++Builder. If you haven’t already, check out what Allen, Nick, Chris, and Seppy are saying. For the Tiburon release cycle, since much of the debugger had previously been Unicode-enabled, I’ve been working on mostly non-debugger things, including being heavily involved in the "Unicodification" of the other parts of the IDE. That said, those of us on the debugger team were still able to include a few new features in Tiburon. This article will describe one of the new features.
In Tiburon, we’ve added support for Vista Wait Chain Traversal. Wait Chain Traversal is made possible by new APIs included in Windows Vista and Windows Server 2008, and as such, this new debugger feature is only available if you are running on one of those OSes. For reference, the MSDN link that describes this feature is http://msdn.microsoft.com/en-us/library/ms681622.aspx.
This feature allows you to get detailed information about thread deadlocks that occur in your program. This can make it much easier to debug problems that traditionally have been very hard to debug. Not all types of thread deadlocks can be debugged using Wait Chain Traversal. As mentioned in the above referenced MSDN article:
WCT currently supports the following synchronization primitives:
- ALPC
- COM
- Critical sections
- Mutexes
- SendMessage
- Wait operations on processes and threads
To give a sense of how this feature is implemented in Tiburon, I’ve included the following screenshot:

You’ll see that in the Thread Status view, a new column, titled "Wait Chain" is shown. This column only shows up if you’re running on an OS that supports Wait Chain Traversal. In the screenshot, a program that is deadlocked has been paused in the debugger. Let’s take a look at what the new column in the thread view is telling us:
- The main thread is blocked waiting on Thread. In this case the main thread has called WaitForSingleObject on a thread handle. The thread being waited on is the thread with a "Threaad Id" of 3792 (the third thread in the list)
- The thread being waited on is, itself, blocked. In this case it is waiting for a SendMessage call to return. The message has been sent to a window that is owned by thread 2792 (the second thread in the list)
- That thread (2792) in turn is waiting to get access to a CriticalSection. Basically, the message loop for this window, in response to the message sent by thread 3792, has asked for a CriticalSection. However, as you can see, that CriticalSection is currently owned by thread 3792.
So basically, we have two threads (1284 and 2792) that are waiting for a third thread (or for a resource owned by that thread). That thread in turn is also blocked, waiting for something on one of the other threads. This leads to the deadlock. The intention is that with the extra information about each thread involved in the deadlock, it will be much easier to debug and fix the problem leading to the deadlock. This is a welcome addition to the OS and in turn to Delphi and C++Builder.
One final note: Although the above screen shot shows this feature using a C++Builder test case, Wait Chain Traversal also works with native Delphi programs.
Share This | Email this page to a friend
Posted by Chris Hesik on July 21st, 2008 under CodeGear Debugger |13 Responses to “Tiburon Preview: Vista Wait Chain Traversal”
Leave a Comment
Server Response from: dnrh1.codegear.com

RSS Feed
July 21st, 2008 at 1:13 pm
Wow. Now that is a welcome feature and can certainly save a lot of time when one is trapped in a dead lock situation. Thanks.
July 21st, 2008 at 1:24 pm
Cool!
July 21st, 2008 at 1:53 pm
Hi Chris,
Great! Quick reminder, maybe, one-day, when time permits, it would be nice to have specialized evaluators for C++ STL (standard) containers… Or at least to have something like a debugger extensibility API (lower level) developers could use to add their own debugger extensions and even override existing debugger APIs)… Something like gdb, except that gdb is super weird (trust me, now I got to know…) - see the stl containers evaluator implementation in 6.8.x… and outside (gdb wiki)
Just a quick reminder…
Best Regards!
Daniel
July 21st, 2008 at 2:39 pm
Why is the codegear blog web site so wide? Even if I maximise the browser window on my MacBook I have to scroll horizontally to read the post. It happens in both Safari and Firefox. Some of the blogs, like David I.’s, are OK but all the ones using the same template as this page are not.
July 21st, 2008 at 4:07 pm
Simon –
It is because of the image.
July 22nd, 2008 at 7:04 am
Wow, first good reason to leave Win XP behind.
July 22nd, 2008 at 7:23 am
[...] We have a Seppy sighting! And a Chris Hesik sighting! [...]
July 22nd, 2008 at 10:17 am
Now allow each thread to have a thread name property (via the RaiseExcept clutch) and the messages become even more descriptive.
Perhaps you can color the cell red when a cycle is detected (as in the example above)
Splendid!
July 22nd, 2008 at 12:44 pm
Ritsaert,
The glyphs in the thread view will indicate "cycle detected". In the screenshot, note that the glyphs in the thread view have a red exclamation point overlay — that indicates the cycle.
Good idea for using the thread name rather than the thread id in the wait chain messages. I’ll look into doing that.
Chris
July 26th, 2008 at 2:52 am
This is too strong!
July 27th, 2008 at 8:10 pm
Now all I need to do is to convince my client to upgrade to Tiburon and to Vista
August 12th, 2008 at 10:13 am
[...] Tiburon Preview: Vista Wait Chain Traversal http://blogs.codegear.com/chrishesik/2008/07/21/34833/ [...]
November 3rd, 2008 at 12:01 pm
[...] Chris Hesik blog post: Tiburon Preview: Vista Wait Chain Traversal [...]