6

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?

Chris Moutray
  • 18,029
  • 7
  • 45
  • 66
Rocky Singh
  • 15,128
  • 29
  • 99
  • 146
  • The current thread is likely not a managed thread. You can run `!threads` to get a list of managed threads in the process. – Remus Rusanu May 04 '12 at 16:39
  • That is what I am confused of. I ran a web application. Click button on one page on browser and the application shuts down. Where is the unmanaged thread playing role here? – Rocky Singh May 04 '12 at 16:42
  • *All* managed applications are hosted in a process. There is no 'managed process' concept. Therefore all managed apps will have unmanaged threads. – Remus Rusanu May 04 '12 at 16:50
  • besides, why are you sing the x86 tools? You're not really running 32 bit code, are you? – Remus Rusanu May 04 '12 at 16:53
  • How can I get the stacktrace of my dump? Yes in my taskmanager it is showing w3wp.exe*32 running. – Rocky Singh May 04 '12 at 16:54
  • Did you run `!threads`? What did it produce? Are you sure ADPlus created a *full* dump, not a minidump? – Remus Rusanu May 04 '12 at 17:08
  • Sorry for my lack of knowledge in this field but I ran this command on adplus C:\Program Files (x86)\Debugging Tools for Windows (x86)>ADPlus -crash -pn w3wp. exe -NoDumpOnFirst -o C:\dumps and that created a dump. How can I know if it is a full or mini dump? – Rocky Singh May 04 '12 at 17:18
  • If you run `~*` in windbg after you open the dump, how many threads does it show? 1 or more? 1 would indicate minidump. When you open the dump file, does Windbg prints this line: `Loading Dump File ... User Mini Dump File with Full Memory` or something else? – Remus Rusanu May 04 '12 at 18:37
  • I would also try takign the dump with Dr. Watson: [Using Dr. Watson to Create a Dump File](http://msdn.microsoft.com/en-us/library/windows/hardware/ff560104%28v=vs.85%29.aspx). I'm not familiar with ADPlus and whhat is different in how it takes the dump. – Remus Rusanu May 04 '12 at 18:47
  • On running ~* I got this: 0:000> ~* . 0 Id: 2bec.36f4 Suspend: -1 Teb: fff5b000 Unfrozen Start: clr!SVR::gc_heap::gc_thread_stub (6ca09735) Priority: 2 Priority class: 32 Affinity: 40 – Rocky Singh May 04 '12 at 19:02

4 Answers4

9

This will return the stack trace of each thread, you'll be able to see the stack trace of the managed ones: ~*e !clrstack

BornToCode
  • 9,495
  • 9
  • 66
  • 83
7

You can type !pe to get the exception or ~#s to switch to the faulted thread. !clrstack should work then.

Thomas Bratt
  • 48,038
  • 36
  • 121
  • 139
2

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 :|

prasadrahul
  • 105
  • 5
0

Just follow the ms tutorial: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/debugging-managed-code

There is described how to load correct version of needed extensions for managed code and for both scenarious: 1) dump from same machine and 2) dump from other machine.

Mitja Gustin
  • 1,723
  • 13
  • 17