Re: How to recover from a EXCEPTION_STACK_OVERFLOW?



Hi Oleg!

You simply should be aware that when you run heavy operations (like
MiniDumpWriteDump) in the process
that has just exhibited unhandled exception, the process state can be
corrupted badly enough for those operations to fail.

I thought about it.

In managed applications, probability of such fatal state corruptions
is lower than in native ones, though.

It is exactly what I tought too. The primary purpose is to catch unhandled
_managed_ exceptions. In most cases it sould be possible to create a
MiniDimp even if there has been an unhandled managed Exception.

In case of an StackOverflowException, I will try to use Jochens Assembler
Routine to recover from that.

Various issues related with reliability of exception filters and
just-in-time debugging have been discussed in this newsgroup before, e.g.
you can
find this thread interesting:
http://groups.google.fi/group/microsoft.public.win32.programmer.kernel/browse_thread/thread/aa0bff4829bf3a44

Your posting within this thread (the last one) is quite informative! Maybe I
can implement more than one method to create the MiniDump:

Method A: The registered custom Exception Filter calls MiniDumpWriteDump
from a new thread within the same process
Method B: The registered custom Exception Filter signals a Watchdog Process
which creates the dump
Method C: The Watchdog Process is attached as a Debugger to the "real"
Process and creates the dump without the need to setup an custom Exception
Filter.

The user of the Component may choose what is nessersary in the concrete
case.

Maybe you can answer me the following question too:
If Method C will be implemented, how much performance does it cost? And one
which operations? Where does the performance - degradation come from? The
Debugger-Events?

There are two basic options:

1) Use just-in-time debugger configured in Registry, system-wide.
The problem with reliability of just-in-time debugging is the same as
with MiniDumpWriteDump - JIT debugger has to be started from the
inside of the crashed process, using CreateProcess function, and
CreateProcess itself can fail because of corruption of the process'
state (e.g. process heap).

Ok. If I understand this correctly, choosing the method will not be any
safer than creating a Thread in-process which creates the dump (new Process
vs. new Thread).

2) Run the application under debugger all the time (that's what
Jochen meant, probably, and that's also what ADPlus (crash mode) and
similar tools do).
This is much more reliable than JIT debugging, since it is not
affected by the possibly corrupted internals of the crashed process.
Also, it does not depend on Registry.

This would be Method C.


A last question: Can Method C be implemented without installing the
"Debugging Tools for Windows" on the users machine? This is the main reason
for me to implement an own component. The first solution I have tried to
implement is to create a "mini-installation" of the Debugging Tools for
Windows (just with cdb, adplus and the needed dlls). But when looking at
redist.txt, you can see that only "dbghelp.dll", "symsrv.dll" and
"srcsrv.dll" may be redistributed.

"MiniDumpWriteDump" is implemented within "dbghelp.dll", so the distribution
would be possible. But may I implement an "Watchdog Debugger" by using just
the redist dll's?



GP


.



Relevant Pages

  • Re: Prohibiting "Visual C++ Runtime Error" dialog box?
    ... >> I added some code to my program to do MiniDumpWriteDump on exception. ... >> exception or corruption cases are caught by MiniDumpWriteDump. ... > your own filter using SetUnhandledExceptionFilter function. ...
    (microsoft.public.vc.debugger)
  • Prohibiting "Visual C++ Runtime Error" dialog box?
    ... I added some code to my program to do MiniDumpWriteDump on exception. ... exception or corruption cases are caught by MiniDumpWriteDump. ... Bae, Hyun-jik ...
    (microsoft.public.vc.debugger)
  • Re: Function names for managed callstack under SOS debugging of .NET 2.0 app
    ... API to setup the default unhandled exception handler for all the unhandled ... and generating the mini-dump. ... MiniDumpWriteDump to write out the minidump, I tried to use windbg to ...
    (microsoft.public.vsnet.debugging)
  • Re: SBS 2003 BOSD (mrxdav.sys), Help Needed Please
    ... Cris Hanna [SBS - MVP] ... MVPs do not work for Microsoft ... Use!analyze -v to get detailed debugging information. ... exception record and context record. ...
    (microsoft.public.windows.server.sbs)
  • Re: Mixed assembly crashes on exit
    ... On the first development machine: I have now set debugging for both the ... I have tried setting breakpoints at various places in MINTERNAL.H. ... I have also tested this code on the 2nd development machine. ... there is an "Exception" message. ...
    (microsoft.public.vsnet.debugging)