Chris’ CodeGear Debugger Blog

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, NickChris, 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:

Tiburon Wait Chain 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:

  1. 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)
  2. 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)
  3. 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.

Posted by Chris Hesik on July 21st, 2008 under CodeGear Debugger |



13 Responses to “Tiburon Preview: Vista Wait Chain Traversal”

  1. Jan Derk Says:

    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.

  2. Giel Says:

    Cool!

  3. Daniel Says:

    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

  4. Simon Says:

    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.

  5. Jeremy Says:

    Simon –

    It is because of the image.

  6. HV Says:

    Wow, first good reason to leave Win XP behind.

  7. Nick Hodges » Blog Archive » Random Thoughts on the Passing Scene #72 Says:

    [...] We have a Seppy sighting! And a Chris Hesik sighting! [...]

  8. Ritsaert Says:

    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!

  9. Chris Hesik Says:

    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

  10. Morteza Ghabooli Says:

    This is too strong!

  11. Dave Nottage Says:

    Now all I need to do is to convince my client to upgrade to Tiburon and to Vista ;-)

  12. Sip from the Firehose : Delphi 2009 and C++Builder 2009 Live Webinars with David I starting tomorrow, August 13 Says:

    [...] Tiburon Preview: Vista Wait Chain Traversal   http://blogs.codegear.com/chrishesik/2008/07/21/34833/ [...]

  13. Paweł Głowacki : Delphi 2009 Online Resources Says:

    [...] Chris Hesik blog post: Tiburon Preview: Vista Wait Chain Traversal [...]

Leave a Comment



Server Response from: blog1.codegear.com