1

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?

2
  • For native apps you can tell the linker to make the stack small - is there a way to do something similar to .NET apps? Commented Oct 5, 2010 at 3:36
  • Hi Michael - I'm not sure about how to specify stack size via linker, but I've read that there's a way to change the size of a particular thread's stack using Editbin.exe. clever suggestion! Commented Oct 5, 2010 at 19:01

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.