Browse by Tags
All Tags »
Debugging (
RSS)
NOTE : if you’re not familiar with SOS (a WinDbg extension for managed code) and leak detection with !gcroot , start by reading an introductory post on the subject. A typical root reference chain for a managed object that is retained by a static GC root would have a pinned object array appear as the rooted object. Here is a typical reference chain: 0:010> !gcroot 0000000002bcaf58 …snipped… DOMAIN(0000000000C1C5F0):HANDLE(Pinned):5017f8:Root: 0000000012761018 (System.Object[])-> 00000000039b3c30...
More than a year after writing my first post touching on the subject of Managed Debugging Assistants (MDA) through the “Callback on Garbage Collected Delegate” case study , it’s time for a brief mention of another useful MDA – “P/Invoke Stack Imbalance” . This MDA fires whenever a P/Invoke call causes an imbalance on the stack. What does a stack imbalance mean? The top of the thread’s stack is pointed to by the ESP register (RSP on x64), and a stack imbalance occurs if the ESP value before making...
Last Wednesday I delivered my last session at the SDP : Production Debugging of .NET Applications . After delivering a similar session in the June DevDays , I thought about how I can make it better by focusing on a smaller set of core debugging scenarios and making sure attendees get a chance to practice them first-hand. Indeed, we had time to discuss and practice the following: Capturing crash dumps and hang dumps with ADPlus, Windows Task Manager, and Procdump Analyzing crash dumps in Visual Studio...
Another piece of great news delivered at //build/ has to do with device driver development. Coincidentally, a few weeks ago I posted a series of baby-steps with Windows driver development , and if you’ve read some of that you’d notice that the driver dev work is very different from application development – you use a different build environment , you deploy drivers manually, and you debug them with a different debugger . This story changes, however, with Visual Studio 11. You can now build drivers...
I had to analyze a memory leak the other day and all I was provided by the customer was a couple of dump files from two points in the application’s lifetime—one dump immediately after initialization, and another dump after the memory leak has accumulated. This is an ideal scenario: now “all it takes” is to compare the two dumps and see which objects are “growing” in memory. That’s, of course, if the leak is actually in managed objects—which isn’t always the case (and VMMap is your friend here )....
Yesterday I delivered a 3-hour session on production debugging at the Castra Center in Haifa. The room was set in the middle of a beautiful art gallery, and the projector was playing my slides on a wall surrounded by paintings. Amidst this cozy atmosphere I was talking about some nasty bugs and how to discover them in a production environment. Source: Ezy.co.il Among the topics covered: Using IntelliTrace in production —we saw an undocumented way to launch IntelliTrace from the command line , capture...
In our C++ Debugging course , there are several scenarios which require WinDbg and cannot be completed in Visual Studio. They all rely on advanced extension commands available in WinDbg. Some examples: Tracing opened and closed handles with the !htrace command Viewing native heap information with the !heap command Loading and executing code in the debuggee process with the SDbgExt extension commands !loaddll , !remotecall Inspecting handles to synchronization objects with the !handle command The...
A dream is coming true. A dream where all the debugging you’ll ever do on your developer box is going to be in a single tool – Visual Studio. In a later post, I will discuss device driver development in Visual Studio 11, which is another dream come true. For now, let’s take a look at how Visual Studio can open kernel crash dumps and perform crash analysis with all the comfy tool windows and UI that we know and love. To perform kernel crash analysis in Visual Studio 11, you will need to install the...
Executive summary: When using the Windows debugger engine to debug optimized C++ code compiled with Visual Studio 11 you can step into inline functions and see local variables that are stored in CPU registers. The current (Visual Studio 2010 compiler) state of affairs is that compiler optimizations are way smarter than the debugger engine, which lacks the information necessary to map a fully optimized binary back to the source code in a reliable manner. This is why C++ developers don’t like debugging...
We have already seen VMMap as a tool for inspecting memory utilization and the layout of a process’ virtual address space. The latest VMMap version (rush to download!) ships with a memory allocation profiler for VirtualAlloc() and HeapAlloc() calls. Additionally, the tool can display the allocating call stack for every heap block. Sounds interesting? Here’s how to use it. You launch VMMap, and instead of inspecting an existing process, you tell it to launch and trace another process. (It uses Microsoft...
In the previous post on stack corruptions , we have discussed the case where the stack becomes corrupted but still contains a chain of EBP references which allows for manual reconstruction. (For background reading, see this article on EBP stack reconstruction and calling convention nightmares on x86 .) Below is a call stack from an application crash dump. The reported crash was an access violation inside a module called “HelperLibrary” for which we don’t have symbols or source code. The call stack...
Suppose you want a more detailed drill-down into your application's GC heap usage. For example, you want to see if there's fragmentation going on, or if there are lots of large objects, or if the XMLDocument objects you allocated a while ago are finally gone. This is something you can do with the CLR Profiler , another free Microsoft tool that supports memory allocation profiling as well as visualizing the managed heap at the individual object level. Unfortunately, running the application...
Corrupted stacks are no fun at all – when you get a crash dump or a live exception in an application, pretty much the first thing you do is take a look at the call stack. When the stack itself is corrupted, your primary investigation tool is taken away. Still, it is sometimes possible to reconstruct the stack even in face of a corruption. I’ve been showing how in the .NET Debugging and C++ Debugging courses, but by popular demand will show one example here as well. You can follow along on your own...
Synopsis: CLR Stack Explorer obtains reliable call stacks of managed processes, supports any combination of 32-bit/64-bit and CLR2/CLR4. UPDATE [2011/7/20]: If you downloaded CLR Stack Explorer from the above link and are using a recent Windows version, you need to Unblock all the .exe files (right-click, Properties, Unblock) for the tool to run correctly. I have just updated the download location with a self-extracting executable which should solve this problem. I’m happy to announce that CLR Stack...
How can you map the memory usage of your .NET application? We'll start with VMMap , a free Sysinternals tool that visualizes your process' virtual address space. Below is VMMap's output for an example process: The type statistics give you a detailed overview of how memory usage is distributed – there are 240MB of DLLs, 50MB of managed heaps (of which only 10MB are committed), etc. In the bottom details view you can see each individual address range on the heap, including its type, size...
More Posts
Next page »