|
Boost : |
From: Russell Hind (rhind_at_[hidden])
Date: 2003-07-18 09:59:25
Daniel Frey wrote:
>
> I wonder what I'm doing wrong. Dtors, smart pointers, etc. take care of
> my environment when an exception is thrown and allow me to only abort a
> small part (we call it a "session") of the process while the rest is
> still in a perfectly consistent state. Well, maybe it's my fault and I
> should learn how to write code that mixes up the whole memory on every
> small programming error ;)
>
As I mentioned in another thread, we went this route and just shutdown
the thread that had caused the exception so that hopefully we could save
our data (this was on a high-throughput drugs screen system, not an
academic exercise :) ), but ultimately when you get to logic errors like
this, that logic error could have written to wrong memory memory. It
may generate an access violation (on win32) which we caught with SEH,
but could also happen when the AV occured was that the thread had
already scribbled on other data in the process which it did have write
access to the memory. The situation is basically useless from here on
and you might as well have just aborted.
This isn't quite the same as the assertion example I first brought up,
but our threads were all wrapped in code similar to this
__try
{
try
{
.... run thread function
}
catch (...)
{
call unhandled exception stuff (our own func)
}
__except(....)
{
call same unhandled exception stuff
}
This exited the thread, and let the rest of the system. Nice in
principle but can be a waste of time in practice. If you weren't
expecting the exception, then how do you know what has actually gone wrong?
In our case, our priority was to save the data from the last scan and
then the user would have to quite and re-start (scans could take upto an
hour so people tended to not like loosing that amount of time).
But, if that bad thread had screwed up some of the data, it may have
gone un-noticed and so saving the data is a waste of time because it is
invalid, or worse still, you don't know if it is invalid or not.
Russell
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk