.NET Debugging Demos – Information and setup instructions


.NET Debugging Demos



This is a series of debugging demos aimed to help you get some hands on experience in debugging the most common types of Hang/performance, memory and crash scenarios in .net applications.

The demos are written in ASP.NET which means that you do need IIS and .net framework 2.0 installed on the development machine where you install the demos.

Each new demo will have a set of instructions on how to get started but the lab instructions are deliberately kept very brief in order to give you the most chance to explore on your own.  Hints will be available for each demo in case you get stuck.

New demos will be published on http://blogs.msdn.com/Tess as time permits (I am planning to release one new lab per week).

All demos will use the same web site so there is only one application to install for all demos.

Note:  These demos will cause high CPU usage, high memory consumption and crashes, so make sure that you are only installing these demos on development machines where no one else will be bothered by the system hanging or the web server crashing.

Installation


1. Download the demo site (attached to this post) and unzip the files to a folder on your harddrive. (Rev: just uploaded a new version that shouldn’t require 3.5)

2. Set up a new virtual directory in IIS called BuggyBits

3. Browse to the default site http://localhost/BuggyBits/default.htm to make sure that you set up the vdir correctly.

4. Browse to the Company info site http://localhost/BuggyBits/CompanyInformation.aspx to make sure that you can view aspx pages correctly.

5. Download and install the debugging tools for windows from http://www.microsoft.com/whdc/devtools/debugging/default.mspx

6. Run the InternetConnections.reg file by double-clicking it to change the number of outgoing connections you can make to the same site in Internet Explorer (note: any registry modification are done at your own risk, if you feel uncomfortable with this you can view the regfile in notepad and make the changes manually)

7. Install tinyget (comes with the IIS6.0 resource kit http://support.microsoft.com/kb/840671 ) we will be using this for stressing some of the pages in order to produce hangs and memory leaks.

Terminology and tools 

Each demo/lab will assume that you are familiar with the following:

 























Windbg Debugger installed with the debugging tools for windows.

By default this will be installed in the “debuggers directory” c:\program files\debugging tools for windows
Adplus Script for automating taking memory dumps, also installed in the debuggers directory
Debuggers directory Typically c:\program files\debugging tools for windows
SOS Extension for managed/.net debugging. 

Comes with the framework and exists in the Framework directory (usually C:\Windows\Microsoft.NET\Framework\v2.0.50727) for simplicity you can copy sos.dll to the debuggers directory.
Loading SOS Loading SOS in windbg can be done by running .load <path to sos>\sos.dll at the windbg command line, or by running .loadby sos mscorwks (which will load it from the framework directory).  If sos is copied to the windbg directory you can simply type .load sos
Setting up symbols Symbols are needed for native/non-dotnet debugging and for viewing the non-dotnet parts of the stack. See http://blogs.msdn.com/tess/archive/2005/12/05/why-do-i-get-weird-function-names-on-my-stack-a-discussion-on-symbols.aspx for more info.  To set up the symbol path in windbg you run

  .symfix c:\mycache 
  .reload

where c:\mycache is where it will store the local copies of the cached symbols.  If you choose to save workspace information when asked in windbg, this symbol path will be saved for the next debugging session.

Tinyget “TinyGet 5.2 (TinyGet.exe) is a command-line Hypertext Transfer Protocol (HTTP) client that supports multiple threads and looping. You can use TinyGet to test or to troubleshoot HTTP client-to-server communication. By using TinyGet, you can customize your test request by configuring many different factors, including the authentication method, the HTTP version, and the output format. You can also use scripts that specify looping and multithreading.”

See http://support.microsoft.com/kb/840671 for more info.

Some familiarity with the sos commands and windbg is also useful. The following articles may be useful to use as reference material:


Install Windbg


Getting started – Part I


Getting started – Part II


Advanced commands

Available Labs:



























Lab instructions Lab walkthrough
.NET Debugging Demos Lab 1: Hang Walkthrough 
.NET Debugging Demos Lab 2: Crash Walkthrough
.NET Debugging Demos Lab 3: Memory Walkthrough
.NET Debugging Demos Lab 4: High CPU hang Walkthrough
.NET Debugging Demos Lab 5: Crash Walkthrough
.NET Debugging Demos Lab 6: Memory Leak Walkthrough
.NET Debugging Demos Lab 7: Memory Leak Walkthrough


 


 

BuggyBits.zip

Comments (66)

  1. This is the first in a series of about 10 labs on .NET debugging. The lab will use a site called BuggyBits,

  2. Pedro says:

    FYI – This mentions that the code requires .Net 2.0, but I had to install 3.5 to get the Featured Products page to load.

  3. Tess says:

    Thanks for pointing that out Pedro,

    The actual app doesn’t make use of any 3.5 specific stuff so if you want to you can safely remove any using statements for System.Linq and similar and any portions of the web.config that make use of 3.5 dlls. I will try to remove any such references and upload a new version as soon as possible that doesnt require 3.5

    I created the sample in 2008 and didnt think about the references to 3.5 that were added by default. Sorry bout that

  4. Michael says:

    Where I can find the InternetConnections.reg ?

    there is no link in your post

  5. Tess says:

    Hi Michael,

    It should be in the zip file.

    /Tess

  6. Earlier this week I published the first .NET Debugging Demos Lab. If you haven’t downloaded and tried

  7. It was nice to see that so many people downloaded the demo site already and checked out the lab instructions

  8. Essam says:

    I think this will gonna be the seed for a book :)

  9. Hi all, I realize that you probably haven’t all had a chance to look at the Crash lab yet, considering

  10. baal says:

    great, i will make it chinese.

  11. TGIF, almost time for the weekend… but before you leave, here is lab 3. Todays debugging puzzle will

  12. wyc730 says:

    Is the zipfile still available??

    It seems to can’t be downloaded!!

    Such a great lab that I can’t just let it go!!

  13. wyc730 says:

    The zipfile can’t seem to be downloaded !!!

  14. Tess says:

    The zip file should still be available and I just tried downloading it a moment ago and then it worked fine so i suspect there might have been a temporary glitch yesterday.

  15. Last week I published a debugging challenge for Lab 5. It was really interesting to see the results and

  16. Since I already posted a challenge for this lab earlier I didn’t want to wait too long with publishing

  17. Matt says:

    These look really helpful and I have one or two web apps that could use some scrutiny.  Thanks for posting them!

  18. It’s been about a week since I posted the debugging challenge for this lab, things have been a bit busy

  19. This is the last debugging lab in the .NET Debugging Demos series. By now you should have the basics

  20. Tess has posted an excellent series on how to debug your applications using Windbg and SOS dll that ships

  21. We have reached the end of the .NET Debugging Demos series. And we are going to end it with a review

  22. baal says:

    hello , Tess

    tinyget (comes with the IIS6.0 resource kit) is installed on the develop machine(BuggyBits site on the IIS) or the client side(Browse) ?

  23. Tess says:

    baal,

    Tinyget is your browser in this case (the app that sends the http request).  You can install it wherever you want to, just make sure that the servername, url is valid from your location (i.e. change localhost to the server name if you are doing it removely)… also consider that if you run tinyget remotely then you may have other factors like bandwidht issues between client and server etc. to factor in to what you see as far as response times etc.

  24. cramirez says:

    hi tess,

    If I’m running windows xp (iis 5.1). Would this labs work also if I use inetinfo process instead ?

    Thanks

  25. Tess says:

    Hi cramirez,

    it would be aspnet_wp.exe, and should work as long as you’re running .net framework 2.0

  26. You’ve been kicked (a good thing) – Trackback from DotNetKicks.com

  27. SharePoint Debugging and Logging Tips and Tricks

  28. I&#39;ve long needed a single source to point people to when it comes to debugging and logging in SharePoint

  29. fractalnavel says:

    If broken it is, fix it you should : .NET Debugging Demos – Information and setup instructions fantastic

  30. If you have hangs, performance, memory issues, exceptions or crashes in Silverlight applications you

  31. James says:

    Hey Tess,

    I absolutely LOVE what you have done here!  These labs are great; I never thought reading about diagnosing memory problems could actually be entertaining, but you have made me a believer.

    That said, I included a plug about your podcast in my weekly podcast (http://www.cubertainment.com), and I also plan to cover these labs in a presentation I’m giving at our local .NET user group (lrdnug.org).

    Thanks so much!

    -James

  32. Tess says:

    awesome, hope the presentation at the .net user group goes well:)

  33. Enkelt svar hoppas jag… Jag tänkte visa ett exempel på hur ni kan debugga en låg cpu hängning i asp.net

  34. I know that perhaps not that many of you know Swedish, but for those of you who do, you might want to

  35. Thanks to everyone who attended my talk! Here’s some links related to the talk: My PowerPoint Presentation…

  36. I still have to figure out a way to host the video from the break-out session but until then, here are

  37. fumade says:

    really good article!!!!

    it helps a lot.

  38. A WinDbg Debugging Journey – NHibernate Memory Leak

  39. Ivan says:

    Hi Tess,

    Thank you very much on these excellent labs and TechEd presentation! In a few days I’ll demo couple of labs on Web-Fu! which is the major ASP.NET event in Serbia. It would be impossible without your posts!

    Thanks!

  40. Chakravarthy says:

    Hi,

    If we set the IIS as per step 6, (InternetConnections.reg file ), then should we undo this setting for normal operations ?

    Thanks,

    Chak.

  41. Tess says:

    No need to undo them.  This setting just allows you to make 10 concurrent outgoing connections to the same server instead of the standard 2.

  42. I’ve just finished writing up an e-mail for some new people in my team about starting Debugging and the

  43. Ingeborg says:

    I would really enjoy seeing similar labs without the need for IIS (using WinForms or just plain command-line executables).

    I wrote a couple of trivial examples in native code for my colleagues as a beginner exercise in WinDbg, but I could certainly benefit myself from some .Net examples.

  44. sunny2009 says:

    Hi,

    I want to Implement this Demo Lab

    1. I have Installed IIS 5.1 on my winxp OS

    2. Created Virtual Directory Buggybits

    3. When I type HTTP http://localhost/BuggyBits/default.htm

    getting the error below,( I have checked the Directory Security and anonymous access is enabled.)

    401.3 – Access denied by ACL on resource

    Internet Information Services

    How to get rid of this 401.3 error

  45. Tess says:

    Hi Sunny,

    The message pretty much means what it says, the aspnet account doesnt have access to read from the location on your disk where you stored the content.

    You would either have to give it permissions or put the content directly under inetpub/wwwroot in a BuggyBits folder

  46. sunny2009 says:

    Gave Permissions, Issue Resolved Thanks Tess

  47. elcarlos14 says:

    have anyone done these labs in IIS 7 ? The labs specify the usage of some tools for IIS 6 … not sure if those tools can be installed and used in IIS 7, any ideas ?

    Thanks!

  48. Tess says:

    elcarlos14,

    I have ran these labs on IIS7, both with the 2.0 framework (and 3.5) as well as with the 4.0 framework.

    Both debugging tools for windows and tinyget can be installed and work on Vista, 2008 and Win7, with IIS7.

    Are you having any specific issues? or are you just asking in preparation for doing this?

  49. elcarlos14 says:

    Hey Tess,

    I’m just asking before I get into the labs, thanks for the info!

  50. James Hutchison says:

    This blog has just helped us diagnose what was a diabolical memory allocation issue in IE7. Not only have you saved us from having to possibly re-architect a large chunk of our first release of software, but have given us some valuable knowledge on how to combat such issues when released.

    Many, many thanks.

  51. kev says:

    Hi

    I am trying to open the aspx but its failing , i have installed .net 3.0 framework.

    Are there anyother settings which i need to perform ?

  52. cg says:

    Great labs ! Fantastic work..

    Just a quick question, whats the impact of the Registry edit and restricting/expanding the number of allowable connections per server? After we finish the lab, do we have to put it back somehow or does it not matter?

  53. Sharath says:

    Hi Tess ,

    Brief  me  what are all the setting required to ran these labs on IIS7 , .Net framework 4.0 and also Windows7  .

  54. Tess says:

    Sharath,  

    I don't think there were any specific things i needed to do, I just set it to run in a 4.0  app pool in IIS.  I seem to remember that there might have been some small config changes based on errors, but are you having issues getting it to run?  can you give some specifics?  There shouldnt be anything in there that is 2.0 specific

  55. Sharath says:

    Hi Tess ,

    Actually i new to WINDBG Tool so need your help to analyze application crash dump file . the below is the scenario description

    we are frequently getting "Server Unavailable" error from the application .

    Application developed using VS 2008 , IIS 6.0 , SQL Server 2005 and Windows server 2003.

    Finally choose WINDBG Tool analyze  "Server Unavailable" error and taken application crash dump files from the sever.

    I followed the steps given in this link http://www.develop.com/…/SOS.pdf

    When i ran the command !DumpHeap -stat , getting thousands of objects.

    Here i am getting stuck to identify which object is giving error.

    Please tell me How to identify the object  which is giving error ?  How to fix the error in the above scenario ?

    Thanks

    Sharath

  56. Tess says:

    Sharath,

    Server Unavailable usually means that the process crashed which could be due to a million and one reasons.  The link you mentioned walks through a basic investigation of why an object is not collected which probably doesn't have a whole lot to do with your problem.  The best advice I can give on how to start out is to try going through some of the crash labs in this series and apply the steps to your dump if you got a crash dump.

    Tess  

  57. Sharath says:

    Hi Tess ,

         Can we work these labs in production server ( Means only .Net frame work 2.0 not entire VS 2005 or VS 2008 )?  Because i am getting the following

    Server Application Unavailable

    The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.

    Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

    Is it required entire VS 2005 or VS 2008?

  58. Tess says:

    Not sure I understand…  you should definitely not install any of these labs in a production environment, they are designed to crash and cause memory leaks for learning purposes only.

    If you are referring to whether you can gather dumps in production then yes, you can using debug diag, procdmp, adplus etc. but i would recommend debugging the dumps on a developer machine.

    Windbg is a tool that requires a good deal of background knowledge of debugging which is why i have set up these labs for people to learn, but if your issue is very urgent i would suggest that you contact support as debugging with windbg is not something you neccessarily want to learn under preassure.

  59. Tina says:

    Hi Tess,

    I'm getting frequent APPCRASH error in eventviewer and the application pool gets stopped.

    The error goes as follows:

    Faulting application name: w3wp.exe, version: 7.5.7600.16385, time stamp: 0x4a5bcd2b

    Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdaae

    Exception code: 0xe053534f

    Fault offset: 0x00009617

    Faulting process id: 0x%9

    Faulting application start time: 0x%10

    Faulting application path: %11

    Faulting module path: %12

    My machine is Windows 7 and .NET Framework version is 2.0, I am facing the same issue in version 4.0 also. what could be the reason for this issue?

  60. Senthil Kumaresan says:

    Your blog is really wonderfull

  61. Nice! says:

    The force is strong with you! Great blog!

  62. hornyDev says:

    Tess you're awesome.. I love you.. I mean you're article….

  63. Gaurav says:

    Hi Tess,

    While executing !CLRStack command in WINDBG it shows

    error : OS Thread Id: 0x5d50 (0)

    Unable to walk the managed stack. The current thread is likely not a managed thread. You can run !threads to get a list of managed threads in

    the process.

    I have .net 4 framework and i am usng psscor 4.

    Please suggest a resolution.

    Regards

    Gaurav Aggarwal

  64. Ali says:

    Hi Tess,

    Tinyget is not available in windows 7 platform because IIS 6.0 Resource Kit is not available for the platform. Is there any other application can be used for same purpose?

    Thanks.

  65. Pravin says:

    Thanks Tess for all your blog posts. I was able to solve many performance issue with our application.

    Good luck with your new adventures.