A: 

I wouldn't rule out there being such a handler in Windows, but I've never heard of it.

I think the traceback that you're showing may be bogus. If you broke into the process after some kind of corruption had already occurred, then the traceback isn't necessarily valid. However, if you're lucky the bottom of the stack trace still has some clues about what's going on.

Try putting Sleep() calls into selected functions in your source that might be involved in the recursion. That should give you a better chance of breaking into the process before the stack has completely overflowed.

Dan Breslau
Look at the scroll-bar in the image - it's the bottom of the stack trace :(
Cristi Diaconescu
+1  A: 

That does look at first glance like an infinite recursion, you could try putting a breakpoint at the line before the one that terminates the process. Does it get there ok? If it does, you've got two fairly easy ways to go.

Either you just step forward and see which destructors get called and when it gets caught up. Or you could put a printf/OutputDebugString in every relevant objects destructor (ONly ones which are globals should need this). If the message is the first thing the destructor does, then the last message you see is from the destructor which hangs things up.

On the other hand, if it doesn't get to that breakpoint I originally mentioned, then can do something similar, but it will be more annoying since the program is still "doing stuff".

Evan Teran
"my question is: how can I find where the infinite recursion call starts?" -> I don't know which call causes the process to end - the stack view doesn't show any of my project's code - read my comment on @Dan Breslau's answer.
Cristi Diaconescu
well you didn't mention that the process ends unexpectedly. You made it sound like the process exits (like a return to main) and gets caught up in a destructor.
Evan Teran
I guess my next question is, what is the nature of the program (fairly linear in function, long running service)? And does the hang happen towards the beginning or end of the lifespan? Also given the functions in the call stack, are you using a custom logging mechanism?
Evan Teran
If so, does this occur with logging disabled? You could have an infinite recursion with the logging calling itself somehow.
Evan Teran
+3  A: 

To control what Windows does in case of an access violation (SIGSEGV-equivalent), call SetErrorMode (pass it parameter 0 to force a popup in case of errors, allowing you to attach to it with a debugger.)

However, based on the stack trace you have already obtained, attaching with a debugger on fault may yield no additional information. Either your stack has been corrupted, or the depth of recursion has exceeded the maximum number of frames displayable by VS. In the latter case, you may want to decrease the default stack size of the process (use the /F switch or equivalent option in the Project properties) in order to make the problem manifest itself sooner, and make sure that VS will display all frames. You may, alternatively, want to stick a breakpoint in std::basic_filebuf<>::flush() and walk through it until the destruction phase (or disable it until just prior to the destruction phase.)

Cheers, V.

vladr
+3  A: 

Well, you know what thread the problem is on - it might be a simple matter of tracing through it from inception to see where it goes off into the weeds.

Another option is to use one of the debuggers in the Debugging Tools for Windows package - they may be able to show more than the VS debugger (maybe), even if they are generally more complex and difficult to use (actually maybe because of that).

Michael Burr
They will show the entire stack. Something like: k5000 should be good.
jeffamaphone
A: 

I agree with Dan Breslau. Your stack is bogus. may be simply because you don't have the right symbols, though. If a program simply disappears without the WER handling kicking in, it's usually an out of memory condition. Have you gone investigated that possibility ?