views:

56

answers:

2

Folks,

Debugging a .net 4.0 app using WinDbg (I'm a beginner to WinDbg). I'm trying to break when I hit a stack overflow: (NTSTATUS) 0xc00000fd – A new guard page for the stack cannot be created

Unfortunately, this overflow happens about 2-hours into a long-running process and logs tells me that it doesn't always happen at the same time/place. If I attach to the process in the debugger, the program runs terribly slow...it might take a few days to hit the bug! Is there a way to speed up the app/WinDbg by telling WinDbg to ONLY break for this particular error?

+3  A: 

You can instruct ADPLus to create dumps of the process when exceptions occur. John Robbins has a good article on the subject. You can then use WinDbg to debug the dump file(s).

Be aware, that the original adplus.vbs has been replaced by adplus.exe, which is supposed to provide the same functionality. In my experience there are a few problems with the new implementation, so you may need to use the old script, which is still available as adplus_old.vbs.

Brian Rasmussen
Hi Brian - great article! I learned a lot from reading it. It turns out that using ADPlus to dump only Second Chance exceptions is still running too slow (thus filtering for a specific exception is likely the same performance or slower). I think in all cases it seems like there's no way around the debugger overhead. However, I came up with another solution - I ran my process for an 1.5 hours and then attached/dumped. Seems like the stack is slowly growing over time so I didn't quite need to wait until it overflowed.
SFun28
Great, glad I could help.
Brian Rasmussen
+1  A: 

Usually, attaching a debugger would not slow down an application too much (compared to starting the application from the debugger, which will set the heap in debug mode).

But by default, the debugger will trace events (exceptions and OutputDebugString), and in your case, there may be too much of them. After attaching with the debugger, you can disable all exception handling. (Menu Debug/Event Filters, or command sxi). You have to change the handling for all events (sxi * means unknown events, and does not apply to all events). You can also disable all tracing with .outmask-0xFFFFFFFF. Then enable only the stack overflow event with sxe -c ".outmask /d" sov

plodoc
@plodoc - thanks for this information!
SFun28