views:

230

answers:

2

I'm analysing a deadlock that's occurring when using a native library alongside managed code. I'm using WinDbg to debug the problem with the intention of saving a dump such that the vendor might observe the issue on their premises.

When attaching to the problematic process I see the following message before any call stacks:

WARNING: Stack unwind information not available. Following frames may be wrong.

The frames actually look correct when attached directly to the process. However, when I take a dump of this file and then open the dump in WinDbg on another machine, one of the stack frames is different (the above error is displayed too.) This originally had the vendor stumped, as the code path seemed impossible.

I took the dump using:

.dump /ma filename.dmp

What would cause this discrepancy, and is there anything I can do to reliably analyse a dump file's call stacks? Might there be any other misrepresented data I should be aware of?

+2  A: 

This sounds like you might have mismatched pdbs. Have you tried the !chksym and !itoldyouso commands? eg see the Bugslayer article

Another thing to try is !sym noisy that should show you which pdb files are being loaded.

See also MSDN blog

the_mandrill
+1  A: 

The warning is telling you that the debugger cannot associate one or more addresses on the stack with existing module information. As managed code is compiled on the fly by the CLR there are no corresponding modules for the code and thus the warning.

The SOS command !clrstack has the necessary info from the CLR to display a meaningful stack (or at least without the warning). If you use any of the native stack dump command, you'll see this warning for managed code.

The upcoming book Advanced .NET Debugging has additional details. See http://advanceddotnetdebugging.com/

Brian Rasmussen
Thanks Brian. So I should expect that warning whenever debugging threads running managed code in WinDbg? That's good to know, however the issue I'm seeing is that an unmanaged stack frame is different when debugging locally when compared to debugging the dump file on a different machine. Thanks for the link -- I'll have a read.
Drew Noakes
I figured you were debugging managed code because of the .NET tag. You will see the warning if you dump the native stack for a thread running managed code as WinDbg doesn't recognize the managed calls. With SOS you get the correct managed view and thus no warning. However, it can still be useful to dump the native stack in which case you just have to ignore the warning. As for your other question: Could you elaborate a little on how the stacks differ between local debug and dump debug.
Brian Rasmussen
I'm debugging a mixture of .NET and native code via interop. I'll provide some more info when I'm able to repro the issue. Thanks again.
Drew Noakes