Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2003-09-26 15:20:30


At 08:40 AM 9/26/2003, David Abrahams wrote:

> ... discussion of SEH cases ...

Let me try to summarize your points, to make sure I understand them:

(1) Exceptions (and signals) from the operating system may come at times
when the C++ exception handling mechanism is unprepared to unwind the
stack. For example, in a nothrow region such as a destructor.

(2) Because of (1), such operating system exceptions or signals should not
be trapped and converted to a C++ exception throw. To do so risks serious
failure.

(3) It is useful, however, to call logging or stackdump facilities, and
then to terminate the program. ( But sometimes, such as during interactive
debugging, trapping to the debugger would be the most useful action.)

Is that summary correct (although much simplified)?

It doesn't seem that (3) is always safe. The problem may have occurred in
one of the logging or stackdump facilities themselves, for example. Calling
them again might cause a loop. That could be protected against by a static
"been_here_before" bool set the first time through. If it is true (the
second time around), just terminate without any log/dump attempt.

How should "terminate the program" be implemented? std::abort()? Remember
that a major objective of catching the structured exception or signal in
the first place was to ensure a non-zero return value from the program
(rather than getting a dialog box or some other non-useful behavior).

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk