[RFC] C++ vs forced unwinding
Fri Apr 11 04:19:00 GMT 2003
On 10-Apr-2003, Richard Henderson <firstname.lastname@example.org> wrote:
> On Thu, Apr 10, 2003 at 06:11:12PM -0700, Mark Mitchell wrote:
> > Does POSIX say anything about thread cleanup functions that don't
> > return? (That's essentially what will happen if the "catch (...)"
> > clause decides not to rethrow.)
> Unfortunately, POSIX only defines C bindings, so this isn't
> covered in any standard whatsoever.
There's several different ways in which a cleanup function could
(1) it could go into an infinite loop
(2) it could terminate the program, e.g. by calling exit(),
_exit(), _Exit(), abort()
(3) it could terminate the thread, by calling pthread_exit()
(4) it could longjmp out
(5) it could throw an exception
The POSIX standard doesn't cover (5). But it should cover (1)-(4),
and IMHO the behaviour in all of those cases except (3) is defined
in sufficient detail that it does not need any additional wording.
In case (1), the behaviour is defined just by saying that
the cleanup function is called; if the cleanup function loops,
then so be it. In case (2), the behaviour is defined just
by saying that the process terminates.
In case (3), it would be sufficient to say that the thread
terminates; however, there is the issue that pthread_exit()
invokes thread cleanup functions, so you would potentially
have a loop there; perhaps that should be undefined behaviour.
In case (4), the POSIX standard explicitly says that the behaviour is
Fergus Henderson <email@example.com> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
More information about the Gcc-patches