Discussion:
What happens during structured exception handler?
(too old to reply)
Chris Shearer Cooper
2008-08-29 13:53:27 UTC
Permalink
In my 32-bit Windows application, I have a standard structured
exception handler set up :
__try
{
// Do a bunch of stuff here
}
__except(GenerateDump(GetExceptionInformation()))
{
}

In my GenerateDump() function, what is the state of the rest of the
program? Most importantly, is it like a debugger in that all of the
threads in the application are frozen? I am calling MiniDumpWriteDump
in GenerateDump() but I would also like to write out additional
information on the state of the program, but (for example) I don't
want to step through the contents of an array if some other thread
might still be running and altering the array contents.

Thanks,
Chris
Alexander Grigoriev
2008-08-29 14:35:42 UTC
Permalink
All other threads are still happily chugging along.
Post by Chris Shearer Cooper
In my 32-bit Windows application, I have a standard structured
__try
{
// Do a bunch of stuff here
}
__except(GenerateDump(GetExceptionInformation()))
{
}
In my GenerateDump() function, what is the state of the rest of the
program? Most importantly, is it like a debugger in that all of the
threads in the application are frozen? I am calling MiniDumpWriteDump
in GenerateDump() but I would also like to write out additional
information on the state of the program, but (for example) I don't
want to step through the contents of an array if some other thread
might still be running and altering the array contents.
Thanks,
Chris
Chris Shearer Cooper
2008-08-29 14:52:23 UTC
Permalink
Argh. But the structured exception handler is called inside the
thread that had the problem, so at least I know that one particular
thread isn't doing anything while I'm processing the structured
exception?

Thanks,
Chris
Volodymyr M. Shcherbyna
2008-09-03 09:59:25 UTC
Permalink
Yes, if there is exception, system searches for exception handler which is
registered for a given stack frame and call it, you are the one who is
running on this stack frame.
--
Volodymyr, blog: http://www.shcherbyna.com/
(This posting is provided "AS IS" with no warranties, and confers no
rights)
Post by Chris Shearer Cooper
Argh. But the structured exception handler is called inside the
thread that had the problem, so at least I know that one particular
thread isn't doing anything while I'm processing the structured
exception?
Thanks,
Chris
Jeroen Mostert
2008-08-29 17:40:45 UTC
Permalink
Post by Chris Shearer Cooper
In my 32-bit Windows application, I have a standard structured
__try
{
// Do a bunch of stuff here
}
__except(GenerateDump(GetExceptionInformation()))
{
}
Generating a dump from within the process is an iffy idea for a number of
reasons, not the least of which is that stack or memory problems could
prevent you from successfully dumping. This is why Dr. Watson (and its close
relative Windows Error Reporting) run externally. Basically, the problem is
that your process state might be corrupt if you get an exception, so it's
hard to guarantee that whatever you're trying to save is even accessible,
let alone meaningful. In the worst case you end up with no dump at all.
Post by Chris Shearer Cooper
In my GenerateDump() function, what is the state of the rest of the
program? Most importantly, is it like a debugger in that all of the
threads in the application are frozen?
No, and that's another reason why you'd usually want an out-of-process
solution. You'd want to call SuspendThread() on every thread in the process
before dumping.
Post by Chris Shearer Cooper
I am calling MiniDumpWriteDump in GenerateDump() but I would also like to
write out additional information on the state of the program, but (for
example) I don't want to step through the contents of an array if some
other thread might still be running and altering the array contents.
That's if you're *lucky*. Accessing the array might segfault if there's
memory corruption. Now, on the plus side, if that happens, you can at least
say you tried and it's better than nothing. :-)
--
J.
Remy Lebeau
2008-09-05 08:58:49 UTC
Permalink
Post by Chris Shearer Cooper
In my GenerateDump() function, what is the state of the rest of the
program?
Happily chugging along. There are several documents on MSDN that describe
the inner workings of SEH exception handlers in great detail. I suggest you
read them.
Post by Chris Shearer Cooper
Most importantly, is it like a debugger in that all of the threads
in the application are frozen?
No.


Gambit

Loading...