Windbg: Unable to walk the managed stack
Question
Via Adplus I attached a process (in my iis I ran a website)
C:\Program Files (x86)\Debugging Tools for Windows (x86)>ADPlus -crash -pn w3wp .exe -o C:\dumps
Below is the code to reproduce stackoverflow exception of that website:
protected void Page_Load(object sender, EventArgs e)
{
}
public void Hello()
{
Hello();
}
protected void Button_Test_Click(object sender, EventArgs e)
{
Hello();
}
Dump created for me was at:
C:\Dumps\Crash_Mode__Date_05-04-2012__Time_21-44-2020\PID-12452__W3WP.EXE_DefaultAppPool__1st_chance_Process_Shut_Down__full_2bc0_2012-05-04_21-45-53-704_30a4
I opened this dump in windbg and ran these commands
0:000> .loadby sos clr
0:000> !clrstack
and I got the following message
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
Can you help me fixing it? How can I trace the location of error?
Solution
You can type !pe to get the exception or ~#s to switch to the faulted thread. !clrstack should work then.
OTHER TIPS
This will return the stack trace of each thread, you'll be able to see the stack trace of the managed ones:
~*e !clrstack
As Remus pointed out that the current thread is not a managed thread. ~ on windbg will give you the list of threads and if you watch closely (my bad monitor made it worse for me :P) there is a . (dot) before the current thread. You need to change it to a managed thread - which you can do by ~s.
Now I will call upon debugging guru to help me - how to find which thread is a managed thread ? I was told by a colleague that generally thread 0 is a managed and I was able to escape until this question :|