From: Guy Bolton King (guyk_at_[hidden])
Date: 2000-05-30 05:50:37
This has been a bugbear of mine for some time, and was the topic of a
thread on the accu-general mailing list earlier this year.
Interestingly enough, David, your solution is significantly less
complicated than mine, and seems to do the job fine. I have one gripe,
and that is the call to UnhandledExceptionFilter() in your
The next paragraph has some SEH-specific jargon; a read of the relevant
sections of the SDK and/or the mentioned article is _very_ useful.
A quick (hoho) rereading of Matt Austern's classic "Crash Course on the
Depths of Win32 Structured Exception Handling" (MSJ, January 1997) shows
that a faulting process that has no exception filters returning
EXCEPTION_EXECUTE_HANDLER will have UnhandledExceptionFilter() called in
the _filter_ of the exception handler that wraps the call to the entry
point of the process. The fact that it is called in the filter is very
important; it means that OS's exception-handler dispatch function
(RtlDispatchException()) hasn't yet attempted to unwind the stack, so
when the debugger attaches, all is well.
Therefore, your call to UnhandledExceptionFilter() shouldn't be
necessary, as you'll see if you comment it out.
As to how that `throw' in your se_translator() is magic, I don't know.
I tried to look at the dissassembly of __CxxFrameHandler and
__InternalCxxFrameHandler, but my EULA-violation-sensitive sunglasses
went black (or rather, like you, I find this mucking about a tad
tedious). At a guess, a re-throw from an se_translator marks the
exception as unhandlable by catch(...) blocks.
Two issues remain: se_translators are thread-local, so
_set_se_translator must be called for every new thread. My
minimally-intrusive solution involves an iostream-style static
initialiser for the main thread, and a replacement _beginthreadex().
Of course, I too have been thinking about writing this up; getting round
to it has been another matter.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk