Re: [c++-pthreads] Re: thread-safety definition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] Re: thread-safety definition



On Mon, Jan 12, 2004 at 04:56:39PM -0500, Jason Merrill wrote:
> On Mon, 12 Jan 2004 14:18:39 -0500, Ted Baker <baker@xxxxxxxxxx> wrote:
> 
> >> ... It sounds as though a lot of people are seriously 
> >> considering the idea of allowing exceptions to escape from destructors.
> >> .... it is _absolutely vital_ 
> >> that destructors never be allowed to throw under any circumstances.
> >
> > Right!  This is what we decided with Ada.  That is why
> > cancellation (task abort) is disabled during exception propagation
> > and finalization routines of controlled object (execution of
> > destructors).
> 
> Can a finalization routine throw a normal exception in Ada?

No.  If a finalizer tries to propagate an exception it is either
ignored totally, or converted to a Program_Error exception at the
next safe point for an exception to be propagated.  (See detailed
rules below.)

--Ted

[ARM 95]:

It is a bounded error for a call on Finalize or Adjust to
propagate an exception. The possible consequences depend on what
action invoked the Finalize or Adjust operation:

 For a Finalize invoked as part of an assignment_statement,
Program_Error is raised at that point.

 For an Adjust invoked as part of an assignment operation, any
other adjustments due to be performed are performed, and then
Program_Error is raised.

 For a Finalize invoked as part of a call on an instance of
Unchecked_Deallocation, any other finalizations due to be
performed are performed, and then Program_Error is raised.

 For a Finalize invoked by the transfer of control of an
exit_, return_, goto_, or requeue_statement, Program_Error is
raised no earlier than after the finalization of the master being
finalized when the exception occurred, and no later than the point
where normal execution would have continued. Any other
finalizations due to be performed up to that point are performed
before raising Program_Error.

 For a Finalize invoked by a transfer of control that is due
to raising an exception, any other finalizations due to be
performed for the same master are performed; Program_Error is
raised immediately after leaving the master.

 For a Finalize invoked by a transfer of control due to an
abort or selection of a terminate alternative, the exception is
ignored; any other finalizations due to be performed are
performed.