• Uncategorized

    Ok, now how do I capture my dump?

    Now we know how it started, some basic information and terminology and why symbols are important, it’s now time to capture our first dump. How? When? Using which tool? It depends… ? From the second post of this series we already know the difference between a hang and a crash dump and depending on the problem we are troubleshooting we know which one we need. There are different ways to capture such a dump but the most used tool in CSS is adplus, and specifically in the IIS and Internet Development team (which I belong to, by the way ?) we also use DebugDiag. I personally prefer adplus, I like it to be run at the command line and be highly configurable through its .cfg files, but there are circumstances (especially unmanaged memory leaks and hanging web applications where the customer can’t be always monitoring the server to readily capture a manual hang dump with adplus) where I find DebugDiag quite useful. Let’s see the differences. Adplus.vbs Adplus is essentially a VBScript (quite large, more than 5.000 lines) file which helps you capture a dump and it accepts some arguments at the command line (or it’s also possible to use…

  • Uncategorized

    Is your UserControl sluggish at loading?

    Here’s an interesting story about performance I had the chance to work on over the last couple of weeks. The object of the call was a UserControl embedded in Internet Explorer, which was very slow to load the first time you browsed the page, but then was performing quite well after that long delay (around 60 seconds); unfortunately closing and reopening the browser caused another 60 seconds delay, which was quite bothering if not frustrating for end users… As you can imagine the control needs to be downloaded, JIT compiled and loaded which of course requires some time depending on how big is the control, how fast (or slow) the Internet connection, how powerful the client etc…, but those 60 seconds where definitely too much. Moreover on Vista we were prompted to run csc.exe and under some circumstances (usually if IE was not run as Administrator) we got a FileNotFoundException. Probing First thing, Fiddler showed that after downloading the first dll (the actual UserControl) we were probing for further localized resources, so we wasting about 15 seconds just for this reason (which is a quarter of the entire time spent waiting on a white IE page…). At the same time…

  • Uncategorized

    Remember to undo your impersonation

    A couple of weeks ago I got an interesting query from a customer, whom had a problem impersonating a service user account by code; the design was a bit more complicated, though: Impersonation not set in web.config By code they needed to impersonate the account logged on the client issuing the HTTP request (this worked fine) By code they needed to impersonate a service account they used to access a backend database (here they were getting an access denied error) Switch back to the previous user, the one logged on the client (again this was working fine) This was quite clearly an impersonation problem, and after some debugging we found the “Access Denied” was being thrown when executing the line highlighted in red in the following snippet, way before even trying to access the network to read the backend database: 1: If CType(LogonUser(username, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token), Boolean) Then 2:    If DuplicateToken(token, 2, tokenDuplicate) Then 3:    Dim identity As New WindowsIdentity(tokenDuplicate) 4:       If System.Web.HttpContext.Current Is Nothing Then 5:          Dim mImpersonatedContext As WindowsImpersonationContext = identity.Impersonate 6:       Else 7:          System.Web.HttpContext.Current.Items("ImpersonationContext") = identity.Impersonate 8:       End If 9:    End If 10: [...] In the screenshot below you can see the “Access Denied” message…

  • Uncategorized

    My goodness, were’s gone my Properties window?!?

    I had a funny half-hour this afternoon, when one of my colleagues took a new call from a customer whom had some troubles with the Properties window in his Visual Studio 2005… The customer reported a weird behavior within the Visual Studio IDE in particular with the Properties window, which was not available despite his attempts to display it both pressing the F4 keyboard shortcut and from the View > Properties Window menu command. Moreover this had the effect to remove the focus from the Visual Studio IDE but apparently nothing else was getting it, and there was a weird Format menu appearing and disappearing… ? It was kind of fun to see Stefano on the phone with the customer, listening to his description and his face getting more and more puzzled… ? Until after some quick research in our internal docs he found a reference to a similar problem, and after a quick test he triumphally called the customer back with the solution after just 20 minutes! ? As I guess you know the Properties window (like other windows in Visual Studio) can be detached from the IDE and left float around the screen; the point here was that…

  • Uncategorized

    Why should we care about symbols?

    I already touched this topic a while ago, but since it’s an important part of the debugging process (and your debugging techniques may vary a lot, depending if you have or not good symbols for your dump) I though would be a good idea to give some more details. And just to jump start on the topic, here’s something I learnt a while ago after wasting a few hours typing commands and looking at inconsistent results… debugging with the wrong symbols could be much worse than debugging with no symbols at all. What are symbols? You can think of symbol files basically as small databases, files which contain source line information, data types, variables, functions and everything else needed to provide names for all lines of code, instead of hexadecimal addresses. They usually have .pdb (or .dbg) extension, and are matched with the actual executable code using an internal timestamp, so it’s very important to generate symbols every time you build the application, also for release builds. If you’ll ever have a problem with your live application and you’ll need to debug it, and if you’ll not have the matching symbols (matching means the symbols obtained from the same exact…

  • Uncategorized

    SyncToy not working on Vista x64?

    I’ve been using SyncToy for quite a few months to keep in sync some folders between my laptop and the other two machines I have in office, and it always worked just great for me (I know, I should be using Groove instead but I’m not happy to have services and programs running when they want, instead of when I tell them to run… ?). When I switched my primary desktop in office to Vista x64, I very quickly discovered that SyncToy was crashing immediately after running it, with no error messages or clues about what is going wrong… I didn’t had much time to spend debugging it and try to figure out what was going wrong (it’s not a must have tool for my work, after all…) so I simply used the laptop to synchronize folders between the two desktops, too… Until this morning, when I had a few minutes free and decided to get back to this problem and try to fix it once for all (and write a blog post on it, too ?); anyway before even opening WinDbg, a research on the Internet brought me to this blog: http://joshmouch.wordpress.com/2007/03/27/synctoy-14-and-vista-x64-error-fixed/. I tried, and it works like a…

  • Uncategorized

    Something you need to know before start debugging

    It may appear as a contradiction after my previous post, but the first thing to do to start analyzing a memory dump is ask yourself: do I really need a dump?!? ? Let me explain: when you need to troubleshoot an error there are a number of things to do before really going down the dump path, simply because not all problems can be resolved in that way… keep in mind that a dump is nothing more than a snapshot of a process at a certain point in time, we can try to understand what happened in the past but with some limitations (as long as the details we are looking for are still in memory), and of course we can’t know what happened to the process after the dump has been taken; exactly like a picture you can take with your digital camera. For example if you are having problems to remotely debug your application, I hardly think a dump can add any value to your troubleshooting… while in case of a memory leak a dump is one of the first things I ask the customer to provide me (but again there are some things before this step). What’s…

  • Uncategorized

    New to debugging? How it all begun (and how could begin for you, too…)

    When I joint Microsoft and the EMEA Internet Dev Support Team in late 2004, I soon realized that I had to build a new skillset to have a future in my new role; before that I was a kind of “self made” developer, in the sense that almost everything I learnt I did in “the hard way”, buying and readings my own books, building a lot of samples, testing, making a lot of mistakes etc… I’ve not had a real mentor, I simply tried to learn from my own experiences, testing things “in real life” and watching the results. And for me in that period the word “debugging” meant only the Visual Studio debugger, run the application and inspect my code hunting for bugs; I never thought to WinDbg, memory dumps and deep system internals (well, to he honest I knew something about memory dumps, but I thought it was too hard for me and never really tried to get my hands dirty with that stuff). Then I join Microsoft and the iDev team, and my horizons expanded. Not too much time had to pass before I realized the kind of cases we were managing required some different (and deeper)…

  • Uncategorized

    Visual Studio as the definitive text editor?

    That’s a clever question and I have to admit I’ve never thought to Visual Studio in this way, even if I tried different text editors and I still have more than one on my machine (Notepad2, Notepad++, PSPad). Anyway, while you thing about it take a few moments to leave a comment on Noha’s post to express your opinion and request features you are missing to turn Visual Studio into the editor for you ? Carlo Quote of the Day: What single ability do we all have? The ability to change. –George Leonard Andrews

  • Uncategorized

    Quickly arrange icons on your toolbars

    This is a trick I learnt a few years ago in Office (don’t remember exactly if was 97 or 2000 ?) since I like to customize my working environment “in my way” (like everyone else, I guess ?), but I don’t like to waste time digging into menus, config files etc if possible… It’s easy: hold the ALT key and simply…: Drag the button to move it in the position you like, also in a different toolbar Slightly drag the button to the right to insert a vertical separator on the left of the icon you are touching Slightly drag the button on the left to insert a vertical separator on the right of the icon you are touching Drag the button down (outside the toolbar) to remove it Of course this works only for icons and button you already have on the toolbar, if you need to add a new one you must do it the usual way (right click on the toolbar and chose the “Customize” command). Oh, this does not work with the Ribbon in Office 2007. Carlo