The Code Slinger

December 27, 2007

SOSEX – New .NET Extensions for WinDBG

Filed under: .NET,SOS,WinDBG — Pete @ 3:43 pm

Somehow I missed this until today, but Steve Johnson has a nice write-up on some extensions he’s written for debugging managed code with WinDBG/SOS.

I find it easier to debug logic and performance issues using other tools like AntsProfiler, Perfmon logs/counters and VS.NET for the most part, however I do use WinDBG/SOS for occasional issues that only crop up in production environments (such as those caused by heavy load, multi-user deadlocks, etc). 

There is a bit of a learning curve to WinDBG, however once you realize how much information is contained within it (e.g. within a full user stack dump of the aspnet worker process), it is often quite easy to find exactly where the issue in the original managed source lies.

There are already commands like !gcroot and !dumpheap that one could use to track some of these issues down.  However of keen interest to a limited WinDBG user such as myself are the new !refs and !dlk commands.

!refs

Though not a replacement, the !refs command supplements SOS’s !gcroot command by allowing you to view  the immediate references from and to a given object.

0:000> !refs 0000000080000db8
Objects referenced by 0000000080000db8 (System.Threading.Mutex):
0000000080000ef0         32    Microsoft.Win32.SafeHandles.SafeWaitHandle

Objects referencing 0000000080000db8 (System.Threading.Mutex):
0000000080000e08         72    System.Threading.Mutex+<>c__DisplayClass3
0000000080000e50         64    System.Runtime.CompilerServices.RuntimeHelpers+CleanupCode

The sample output above shows only heap references, but !refs will also list all references from handles, stacks, registers and the freachable queues.

 

!dlk

The !dlk command allows you to easily spot deadlocks in your application if you suspect deadlock to be the cause of an application hang. If !dlk detects deadlock, the output will list the sync blocks that are held as well as the sync blocks for which each thread is waiting, as well as the type, method, IL offset, and, if symbols are available, the source code and line number at which each thread is waiting:

0:010> !dlk
Deadlock detected:
CLR thread 4 holds sync block 00000000024c6970 OBJ:000000007fff0f80[System.String] STRVAL=SYNC1
             waits sync block 00000000024c6928 OBJ:000000007fff0fa8[System.String] STRVAL=SYNC2
CLR thread 5 holds sync block 00000000024c6928 OBJ:000000007fff0fa8[System.String] STRVAL=SYNC2
             waits sync block 00000000024c6970 OBJ:000000007fff0f80[System.String] STRVAL=SYNC1
CLR Thread 4 is waiting at ConsoleTestApp.ConsoleTestApp.MonitorDeadlockThreadProc()+0xa4(IL) [C:\dev\ConsoleTestApp\ConsoleTestApp.cs, line 195]
CLR Thread 5 is waiting at ConsoleTestApp.ConsoleTestApp.MonitorDeadlockThreadProc()+0xa4(IL) [C:\dev\ConsoleTestApp\ConsoleTestApp.cs, line 195]

1 deadlock detected.

As you can see, !dlk makes it dead simple to troubleshoot this common kind of deadlock in managed code. One important caveat holds true for !dlk: it only works for deadlocks on “sync blocks”. Put more simply, it will only spot locks created by Monitor.Enter (which is used by the C# lock keyword). !dlk will not catch deadlock on other types of synchronization objects, such as mutexes and semaphores.

Very cool stuff.  Thanks Steve!

Advertisements

42 Comments »

  1. These are in fact great ideas in concerning blogging.
    You have touched some fastidious things here.

    Any way keep up wrinting.

    Comment by simcity 5 crack — June 21, 2013 @ 1:50 am | Reply

  2. Hello there, You have done an incredible job. I will certainly digg it and personally recommend to my friends.

    I’m sure they’ll be benefited from this website.

    Comment by alergia pokarmowa u dzieci — June 25, 2013 @ 6:38 am | Reply

  3. There is certainly a great deal to learn about this subject.
    I like all of the points you have made.

    Comment by Cornelius — June 25, 2013 @ 7:58 am | Reply

  4. Currently the solution to the particular issue, how to lose weight swiftly or perhaps how to lose weight quick, includes a regular exercising, personal control and hale and
    hearty diet. Instead of wolfing down your food you chew
    it 20 to 30 times or more until it becomes a liquid in your mouth
    and mixed well with saliva. A good Hypnotherapist for Weight Loss should have a background in Nutrition, Exercise, or both.

    Comment by http://superdietadaproteina.wordpress.com — July 4, 2013 @ 1:30 am | Reply

  5. C on September 29, 1988, one of four children of Wanda and her family, Louis Vuitton Outlet Store was born on 1988?
    Tony Parker finished with 29 louis vuitton outlet
    store points and 12 rebounds for the Bulls, who played without center Joakim Noah.
    Durant may be getting more All-Star players to participate
    in practically all of the damage late to send the
    game to miss one of his two free throw opportunities.
    Durant’s younger and scores easier, but that did not happen,” Brooks said, according to a Nov.

    Comment by http://www.telligentservices.com — July 26, 2013 @ 5:03 am | Reply

  6. While the ability to lose weight all while shoveling various meats down your throat seems heavenly, a good dose of commons
    sense can fire some warning shots to your system.
    This includes logging each meal of the day, logging weight lifting
    regimens, and logging other exercise regimens.
    A good Hypnotherapist for Weight Loss should have a background
    in Nutrition, Exercise, or both.

    Comment by tumblr.com — July 29, 2013 @ 5:05 pm | Reply

  7. What the Hell Results: Sightings: michael kors outlet Custom nozzles
    Pure Power If you watched Monday Night Football game the Giants won their first World Series championship as a California team.
    Everyone knows that the michael kors outlet have a good secondary with Corey Webster and Antrel Rolle.
    Bradshaw approached 1, 200 yards last year — a big reason Minnesota went
    12-4 and claimed the NFC North division. Here are the video
    highlights for New York to take on the Jets this weekend.

    Comment by Michael Kors Bags — August 2, 2013 @ 12:02 pm | Reply

  8. 5 million he would have worn a special” Galaxy” PE.
    Nike chaussure air max is the hot topic among the
    runners. So, who numerous eyes, the best shoes are cross trainers and basketball shoes.
    Its outsole also provide you with the traditional style.

    Comment by greenppl.com — August 5, 2013 @ 11:51 pm | Reply

  9. San Diego at least have his best pass rusher available
    John Abraham is expected to be taken with
    a large pinch of salt. Jones has not had the depth to handle the most difficult schedule in the louis vuitton outlet.
    There is Trent Richardson, Running Back, Alabama Richardson
    was listed as one of the best passers in the game.

    Comment by Louis Vuitton Outlet — August 7, 2013 @ 4:47 pm | Reply

  10. Thank you for sharing your thoughts. I truly appreciate your efforts and I will be
    waiting for your further write ups thank you once again.

    Comment by background check Reviews — August 19, 2013 @ 9:00 am | Reply

  11. When someone writes an post he/she maintains the idea of a user in his/her mind that how a user can understand it.
    So that’s why this post is amazing. Thanks!

    Comment by Darcy — August 25, 2013 @ 7:54 am | Reply

  12. This is very interesting, You’re a very skilled blogger.
    I’ve joinwd your rss feed and look forward to seeking more of your
    excellent post. Also, I’ve shared your web site in my social networks!

    Comment by Gordon — October 24, 2013 @ 3:19 am | Reply

  13. I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it for you?
    Plz reply as I’m looking to design my own blog and would like to know where u got
    this from. many thanks

    Comment by fifa14skill.wordpress.com — December 10, 2013 @ 4:14 am | Reply

  14. Hello there! This post couldn’t be written much better!
    Looking through this article reminds me of my previous roommate!
    He always kept preaching about this. I’ll send this post
    to him. Pretty sure he’s going to have a good read. Thanks for sharing!

    Comment by home builders in delaware — January 20, 2014 @ 5:09 pm | Reply

  15. We’re a bunch of volunteers and opening a new
    scheme in our community. Your website offered us with valuable info to work on.
    You have performed an impressive task and our whole neighborhood will probably be
    grateful to you.

    Comment by portland short sale — January 25, 2014 @ 10:34 pm | Reply

  16. Hi there i am kavin, its my first occasion to commenting anyplace, when i read this piece of writing i thought i could
    also make comment due to this good paragraph.

    Comment by hair styling — February 1, 2014 @ 6:25 am | Reply

  17. http://www.souqarriyadh.com
    موقع سوق الرياض لمنتجات التخسيس و التجميل
    و التبييض,التخسيس,تخسيس الوزن,تخسيس
    البطن,تخسيس الكرش,تخسيس الارداف,
    التنحيف,تخسيس الجسم,التخسيس بدون رياضة,التبييض,تبييض الوجة,
    تبييض الجسم,تبييض البشرة,التحميل,
    تجميل الجسم,

    Comment by تبييض البشرة — February 16, 2014 @ 1:56 pm | Reply

  18. I feewl that is among the such a lot important imfo for me.
    And i’m happy reading your article. However wasnna statement on few general things, The websitee style is wonderful, the articles is in reality great
    : D. Just right activity, cheers

    Comment by beats headphones — March 5, 2014 @ 11:08 am | Reply

  19. Nice answers in return of this difficulty with firm arguments and describing the whole thing on
    the topic of that.

    Comment by club penguin Membership cards — March 9, 2014 @ 8:02 am | Reply

  20. I always used to study article in news papers but now as I
    am a user of internet therefore from now I am using net for posts, thanks to web.

    Comment by boudoir photography — March 11, 2014 @ 5:03 am | Reply

  21. Thanks for sharing your info. I truly appreciate
    your efforts and I will be waiting for your next post thanks once again.

    Comment by best video intro software — April 16, 2014 @ 4:02 pm | Reply

  22. fantastic points altogether, you just gained a logo new reader.
    What would you recommend about your publish that you just made a few days ago?
    Any certain?

    Comment by shortcllw.wordpress.com — April 16, 2014 @ 6:29 pm | Reply

  23. Does your website have a contact page? I’m having trouble locating it but, I’d like to send
    you an email. I’ve got some suggestions for your blog you might be interested in hearing.
    Either way, great blog and I look forward to seeing it grow over time.

    Comment by CHI Hair Straightener — May 7, 2014 @ 11:54 am | Reply

  24. I’ve been exploring for a bit for any high-quality articles or blog posts in this sort of house .
    Exploring in Yahoo I eventually stumbled upon this site.
    Reading this info So i am happy to express that I’ve an incredibly excellent uncanny feeling I discovered exactly what
    I needed. I most indisputably will make sure to don?t overlook this web site and provides it a look on a continuing basis.

    Comment by Horace — May 16, 2014 @ 7:50 pm | Reply

  25. It’s awesome designed for me to have a web page, which is beneficial designed for my know-how.
    thanks admin

    Comment by adult seo — June 19, 2014 @ 3:07 am | Reply

  26. Highly energetic article, I enjoyed that bit. Will there be a part
    2?

    Comment by Hortense — July 1, 2014 @ 6:38 pm | Reply

  27. Just being able to give yourself some down time to unwind and relax is a healthy habit.
    Marion Mccants enjoys writing about massage chair
    recliner and heated massage chair as well as related products.
    Seen as a more effective method than traditional massage because of the stones.

    Comment by Jenna — July 4, 2014 @ 6:02 am | Reply

  28. Without worrying about your gadget when you
    leave the car, you’ll need an i – Pod adapter to
    connect your i – Pod to the stereo and take full control from the
    stereo itself. Startronics at Wilshire Boulevard in Santa
    Monica, California is the place to go if you want to use only the best products and accessories for your automobile.

    Look for an auto shop who has been in business
    for years, so you can rest assured your car will be taken care of properly, efficiently, and effectively.

    Comment by Latashia — July 5, 2014 @ 10:57 pm | Reply

  29. An experienced lawyer can save you from all the hassles and getting arrested.
    Here are a handful of positive aspects of selecting a excellent DUI
    legal professional:. A DUI Lawyer is studied in the
    law, is familiar with the court room procedures, may probably know the police,
    lawyers, attorneys, and other law workers within the court
    system.

    Comment by Carma — July 15, 2014 @ 6:36 pm | Reply

  30. Since it is a sensitive issue, the trial proceedings should always be left in the hands of a professional.

    Not every attorney understands the science behind a DUI nor do all lawyers
    have relationships with expert witnesses that
    can help in your case. Are you still putting yourself and people
    around you at risk.

    Comment by Maximo — July 16, 2014 @ 11:32 am | Reply

  31. If some one desires to be updated with most recent
    technologies after that he must be pay a visit this web site and be up to date daily.

    Comment by Jennifer — July 31, 2014 @ 11:21 pm | Reply

  32. Until now, Im going to make sure that you have to propose
    you ask? So I have been exposed was placing the lady in half, the cognitive and the capability
    become mentalist too studyy minds. Even so in this business to try to get
    into magic, mentalism or stage act. If you keep talk to a person, you make that decision. The
    person who likes become mentalist to be.

    Comment by photos mentalism — August 7, 2014 @ 6:35 pm | Reply

  33. To enter the prize draw, pet owners just need to submit areview of their pet insurance provider.
    The cost of pet insurance, like health insurance for people, varies according to the coverage and the
    age and type of the animal involved. When you are deciding on the
    type of deductible you want, you have to consider that going for the
    highest value will provide lower premiums, but you will spend more on covering the
    clauses not stipulated in the contract.

    Comment by Isabella — August 11, 2014 @ 8:04 am | Reply

  34. If you desire to grow your know-how simply keep visiting this web page and be updated
    with the most recent news update posted here.

    Comment by soigner une fissure anale — August 25, 2014 @ 11:27 pm | Reply

  35. It’s appropriate time to make some planns for the future and
    it is time to be happy. I’ve learn this put up and iif I may I
    want tto suggest you few interesting issues or tips. Maybe you can write subsequient articles
    referring tto this article. I wish to read more issues
    about it!

    Comment by otto-obrien.tumblr.com — August 31, 2014 @ 3:52 am | Reply

  36. It should be noted that it’s advisable to not shoot shot through rifled bores, as the shot
    will degrade the rifling over time. The nighttime range is about 5
    feet and the I-35 can accept a 16-gigabyte memory card. More important, I
    was reminded of one of the most basic and easily forgotten truths:
    In any situation, no matter how barren things may look or
    feel, I can choose which opportunities will sustain me.

    Comment by Hunting In Virginia — September 2, 2014 @ 7:44 pm | Reply

  37. Hey! I could have sworn I’ve been to this site before but after checking through
    some of the post I realized it’s new to me.
    Anyhow, I’m definitely glad I found it and I’ll be bookmarking and checking back frequently!

    Comment by youtube.com — September 12, 2014 @ 3:28 am | Reply

  38. But details safety engineer Andy McLaughlin of Secure System Technologies says the cellphone
    consumer has full manage of the app.

    Comment by facebook security code login — September 26, 2014 @ 11:19 am | Reply

  39. Generally I don’t read post on blogs, however I would like to say that this write-up very
    compelled me to check out and do it! Your writing style has been amazed
    me. Thank you, quite nice article.

    Comment by visit the website — September 28, 2014 @ 11:08 am | Reply

  40. For the past 4 months I was searching the web hoping to locate websites with articles regarding
    foosball parts for sale and found “SOSEX – New .NET Extensions for WinDBG “.
    I just want to say thanks, this is precisely what I needed to see.

    Comment by foosball table — November 3, 2014 @ 1:06 pm | Reply

  41. Awesome Web site, Stick to the great job. Thanks a ton.

    Comment by this contact form — December 27, 2014 @ 3:28 pm | Reply

  42. No introduzcas objetos en el lavavajillas no indicados para lavar en este electrodoméstico el calor puede deformarlos y deteriorarlos hasta dejarlos inutilizables inservibles. La carga de la secadora se mide en kilogramos al igual que en la lavadora, pero a diferencia de esta, para la misma capacidad de carga necesita un tambor de mayor tamaño. El microondas es de los electrodomésticos más versátiles ya que nos permite realizar distintas tareas como calentar, descongelar y preparar alimentos muy rápidamente, lo que supone un ahorro de un 65 aproximadamente en comparación con un horno convencional. Nuestras reparaciones en Vallecas están garantizadas por escrito en los materiales empleados como en la mano de obra.

    Comment by reparacion de freidoras madrid — December 29, 2016 @ 1:20 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: