If broken it is, fix it you should

Using the powers of the debugger to solve the problems of the world - and a bag of chips    by Tess Ferrandez, ASP.NET Escalation Engineer (Microsoft)

Posts
  • If broken it is, fix it you should

    ASP.NET Case Study: Lost session variables and appdomain recycles

    • 108 Comments
    Last night I got a question from one of the readers of the blog that went like this: “We are facing a problem that i cannot understand, every now and than i see that my app domain is recycled (i have a log in the application_end), I check the IIS logs and i don't see a restart of IIS and i know that no one is changing configuration (web.config). I wanted to know if you know of any way that i can pinpoint the reason for that app domain to die? The application pool that i am using...
  • If broken it is, fix it you should

    ASP.NET 2.0 Crash case study: Unhandled exceptions

    • 84 Comments
    For a long time all my case studies have been on 1.1. it’s time to venture out in 2.0 land and look at what may seem like a 2.0 specific issue. I say “may seem” because this case study will only directly crash if you are using 2.0, but as you’ll learn later the problem existed in 1.1 and 1.0, it was just way harder to track down. Problem description: Once in a while ASP.NET crashes and we see events in the system event log like this one Event Type: Warning Event Source: W3SVC...
  • If broken it is, fix it you should

    .NET Memory usage - A restaurant analogy

    • 57 Comments
    My favourite author Simon Singh is a wiz at analogies. In his book The big bang he explains concepts like the doppler effect and the theory of relativity using analogies with frogs and trains that makes it not only easy to understand but you will remember them forever because of the picture they paint in your head. The other day at work I heard one of my colleagues explaining memory usage and why you get out of memory exceptions to one of his customers using a restaurant analogy. I've talked about...
  • If broken it is, fix it you should

    ASP.NET Memory: If your application is in production… then why is debug=true

    • 86 Comments
    Statement “Ensure that the debug="false" on the <compilation> element in the web.config file of each and every ASP.NET application on the server. The default during development is "true" and it is a common mistake to allow this development time setting to find its way onto production servers during deployment. You don't need it set to true in production and it often leads to memory overhead and inefficiencies.” What problems does leaving debug=true cause? There are three main...
  • If broken it is, fix it you should

    .NET Debugging Demos Lab 1: Hang

    • 51 Comments
    This is the first in a series of about 10 labs on .NET debugging. The lab will use a site called BuggyBits, and as the name suggests the bits are extremely buggy. To get started, follow the setup instructions posted here . I have a feeling that these hands-on-labs may generate a lot of questions and although I will try to answer any questions posted in the comments I can’t promise to answer them all so please feel free to answer other readers comments if you know the answer, and make sure that...
  • If broken it is, fix it you should

    .NET Memory Leak Case Study: The Event Handlers That Made The Memory Baloon

    • 45 Comments
    It always feels like issues come in clusters. One week we get tones of cache related cases, next week everyone is stuck in some lock and so on. Lately I have had a number of issues where there were memory leaks related to event handlers. Problem description We have a pretty easy to repro memory leak, even with very few users memory grows at a high rate and the memory is never released. The usual suspects are eliminated, i.e. we know that the app doesn’t cache much or store much or anything...
  • If broken it is, fix it you should

    A Case of Invalid Viewstate

    • 38 Comments
    Last week I was helping a colleague of mine with a viewstate case that turned out to be pretty interesting... Scenario The customer was getting events similar to the following in the eventlog and needed to know why they occurred Event Type: Information Event Source: ASP.NET 2.0.50727.0 Event Category: Web Event Event ID: 1316 Date: 2007-06-11 Time: 09:48:02 User: N/A Computer: MYMACHINE Description: Event code: 4009 Event message: Viewstate verification failed. Reason: The viewstate...
  • If broken it is, fix it you should

    .NET Memory Leak: To dispose or not to dispose, that’s the 1 GB question

    • 33 Comments
    I was looking at a memory dump recently for an issue where the process would grow to over 1 GB and return OutOfMemory Exceptions. Debugging the issue: A full user dump of the w3wp.exe process was taken with debug diag 1.1 when memory was really high. If you are reading this and have no clue what debug diag is, how to get dumps with it, or use leak tracking, here is the download and the usage instructions . The dump itself was 1.34 GB which is basically the memory we have committed (used) so it was...
  • If broken it is, fix it you should

    Are you aware that you have thrown over 40,000 exceptions in the last 3 hours?

    • 51 Comments
    This may seem like a preposterous statement, but unfortunately it’s all too common. In my work I go through a lot of dumps, somewhere in the neighborhood of 5-20 in a day:) Since the information is readily available to me, I usually do a quick check for the number of exceptions that the application has thrown and what types of exceptions they are so I can make the customers aware. More often than not, the applications are throwing a lot more exceptions than the developers expected, or they were...
  • If broken it is, fix it you should

    Debug Diag script for troubleshooting .NET 2.0 Memory leaks

    • 27 Comments
    I have put together a quick and dirty debug diag script for troubleshooting .net memory leaks. (attached to this post) The reason I put it together was mainly to show how you can create your own debug diag scripts but feel free to use it to troubleshoot memory leaks, knowing that it does string parsing on the output so it is a bit prone to errors if sos changes output formats. NOTE: This script will only work on .NET 2.0 x86 memory dumps Mourad recently published a whitepaper on debug diag...
  • If broken it is, fix it you should

    .NET Memory Leak: XmlSerializing your way to a Memory Leak

    • 60 Comments
    I hate to give away the resolution in the title of the blog since it takes away a lot of the suspense:) but I can't figure out a better way to name the blog posts and still keep them nicely searcheable so here we go... This one has come up a number of times, in fact so many that I finally wrote a kb article on it a couple of years ago. I'll give you the link at the bottom of the blog post. I specifically remember one time when I had a case on this. It was a Saturday at 2 am and this customer...
  • If broken it is, fix it you should

    Validation of viewstate MAC failed after installing .NET 3.5 SP1

    • 44 Comments
    After installing .NET 3.5 SP1 you may get Validation of viewstate MAC failed exceptions when doing post backs on ASP.NET pages Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
  • If broken it is, fix it you should

    Why I love the debugger...

    • 30 Comments
    10 years ago, still in college, I started working for a company developing real-time systems for trains in Motorola HC11 assembly. Although very interesting and challenging it was a relief to later move on to some more high-level languages, but in the end, no matter how high-level the programming language you work in, everything comes down to machine instructions and ones and zeros. There is just a bunch of stuff between you and the nitty-gritty that normally you might think you don't need to care...
  • If broken it is, fix it you should

    ASP.NET Performance Case Study: Web Service calls taking forever

    • 30 Comments
    This issue has been pretty frequent since .net came out, and I am bringing it up for two reasons. It is something I think every web developer calling web services should be aware of... and It is a good example of how the product changes based on feedback from support incidents etc. to better suit our customers Problem Description We have an ASP.NET application acting as a GUI to our middle tier (Web Service) and at peak times the application is dead slow. Requests start timing out...
  • If broken it is, fix it you should

    !dumpheap –stat explained… (debugging .net leaks)

    • 15 Comments
    The most powerful command when debugging a managed memory leak is by far !dumpheap. It will show you all the objects on the managed heaps and using the different switches of !dumpheap you can display the output in virtually any way you want. !dumpheap is a function of the sos.dll extension that comes with the framework installation (in the framework directory) and if you have the SDK installed you can find some basic help for it’s usage in C:\Program Files\Microsoft Visual Studio .NET 2003...
  • If broken it is, fix it you should

    Back to Basics - How do I get the memory dumps in the first place? And what is SOS.dll?

    • 20 Comments
    Windbg.exe and its friends can be installed from http://www.microsoft.com/whdc/devtools/debugging/default.mspx Once you have them installed on a machine, you can simply copy the directory where they are installed (usually c:\program files\debugging tools for windows) to any machine that you need them on. No other installation is really necessary. Before we even start with how you get the dumps, you might be interested in what a memory dump actually is... A memory dump is a snapshot of a...
  • If broken it is, fix it you should

    A Hang Scenario, Locks and Critical Sections

    • 19 Comments
    The situation here is that the server at times slows down considerably, or even hangs completely. Requests start timing out and no new requests seem to be getting through. The scenario below is a bit simplified but it shows the technique to find owners, waiters and locations for locks. A quick look with ~* kb (listing the native stack for all threads) shows us that most threads are sitting in this type of stack… 30 Id: d78.c68 Suspend: 1 Teb: 7ff5a000 Unfrozen ChildEBP RetAddr Args to Child ...
  • If broken it is, fix it you should

    ASP.NET Memory Leak Case Study: Sessions Sessions Sessions…

    • 28 Comments
    In ASP.NET 1.1 as you probably know, there are 3 different locations to store session objects. In proc which stores session variables in the cache, State server which stores it in the state service and finally SQL Server . There are of course pros and cons of each but no matter which one you use, you should be careful with how much you store in session state if you want your application to be scalable. For in-proc session state, storing too much in session means high memory usage. For state...
  • If broken it is, fix it you should

    .Net memory leak: Unblock my finalizer

    • 44 Comments
    This time I figured I'd talk about an issue that spans all three debugging scenarios, hangs, memory issues and crashes... yummy:) But first off let me just share a link i found on Mike Stall's debugging blog , the source for .net 2.0 (rotor). Very handy if you want to take a closer look at how things are implemented in the framework. Edit 2010-03-08: Changed the link to the download for the CLI source Problem statement: The application runs fine for hours on end, then suddenly memory...
  • If broken it is, fix it you should

    Debugging Native memory leaks with Debug Diag 1.1

    • 28 Comments
    I often get questions about debugging native memory leaks. In other words, cases where you have high memory usage in your application but you can see that .net memory usage is not all that high. Recently I was helping out on such a case and this post details both generally how you go about troubleshooting these issues as well as what troubleshooting steps we went through in this particular case. Essentially you would go through these steps to troubleshoot a native memory leak: 1. Find out if your...
  • If broken it is, fix it you should

    A .NET Crash: How not to write a global exception handler

    • 10 Comments
    I’ve written quite a few posts on memory issues because that is the type of problem we get most frequently in support, but I thought I’d break it up a little bit with a post on a crash scenario. This is a problem that I have seen a number of times in cases throughout the years and it also turns out to be a pretty nice sample for showing how to debug a stackoverflow crash in .net. Problem description From time to time ASP.NET crashes with the following event in the eventlog: Event Type: Warning...
  • If broken it is, fix it you should

    ASP.NET Crash: System.Security.Cryptography.CryptographicException

    • 14 Comments
    This has been a busy month for blogging for me, I'm up to a whopping 8 posts this month including this one which is the most I have written in any given month (since Feb 2006)... We have seen a few cases lately where ASP.NET apps die due to an unhandled CryptographicException when finalizing a SafeHandle. Here is the explanation of why this happens and what you can do to avoid it. Problem description Intermittently ASP.NET will crash with the following entries in the appication eventlog...
  • If broken it is, fix it you should

    Unable to load DLL ‘dllname.dll’: A dynamic link library (DLL) initialization routine failed. 0x8007045A

    • 13 Comments
    I recently got an email with the following question: “Can you give me some very helpful hints with this one ? I am struggling with the following error in an asp.net application. Exception Message: Internal Error : Unable to load DLL 'RdbNet.dll': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) The RdbNet.dll is an .NET dll from Oracle so I can't debug into it. If I use a windows forms application I never have the error. I have already used procmon...
  • If broken it is, fix it you should

    Capturing memory dumps for 32-bit processes on an x64 machine

    • 17 Comments
    This is an issue that I often get questions around and we often have cases where we have to re-capture memory dumps because the memory dumps were captured the “wrong” way. The short story is: If you are executing a 32-bit process on a 64-bit machine, (which is the default case for IIS on x64 machines for example) you need to capture the dump with a tool that allows you to create 32-bit dumps. How do you know if your process is 32-bit? If you are on a 64-bit machine, you can check...
  • If broken it is, fix it you should

    .NET Debugging Demos Lab 3: Memory

    • 30 Comments
    TGIF, almost time for the weekend... but before you leave, here is lab 3. Todays debugging puzzle will be a Memory investigation. This time we are going to stress the BuggyBits site to create a high memory usage situation and figure out what caused it. This lab is a bit lengthier because I wanted to show various aspects of a memory investigation. Once you know the relationship between the numbers in the dump and perfmon etc. you can often skip some parts, but if it is possible to gather I would...
Page 1 of 11 (261 items) 12345»