This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [basic-improvements] try/finally support for c/c++
- From: Richard Henderson <rth at redhat dot com>
- To: Matt Austern <austern at apple dot com>
- Cc: Jason Merrill <jason at redhat dot com>, Stan Shebs <shebs at apple dot com>, Aldy Hernandez <aldyh at redhat dot com>, gcc-patches at gcc dot gnu dot org, jakub at redhat dot com
- Date: Wed, 6 Nov 2002 10:25:25 -0800
- Subject: Re: [basic-improvements] try/finally support for c/c++
- References: <wvl3cqf7avy.fsf@prospero.boston.redhat.com> <5FB32E42-F137-11D6-946D-000393B2ABA2@apple.com>
On Tue, Nov 05, 2002 at 07:25:18PM -0800, Matt Austern wrote:
> I'm still not 100% sure that I find it completely compelling,
> though. Yes, I do remember the forced unwind stuff, but that
> started from the question of how thread cancellation would
> interact with automatic variables' destructors, which is, um,
> less of a concern for C.
Actually, it is a concern for libc itself. Thread cancelation
is required to release various locks acquired within stdio.
> After all, pthreads was designed and implemented
> with standard C90 in mind; do we really need this sort of
> language change either to implement pthread_cancel or for
> programmers to be able to use it effectively?
We have two choices:
One, libpthread and libc can continue to use a setjmp/longjmp
based solution, which _does_ work within the framework of C90.
This, however, ignores the many many (somewhat misinformed)
bug reports that complain about C++ destructors not being run
at thread cancelation. Despite the fact that POSIX does not
mention C++ at all, one must agree that having destructors run
at thread cancelation is a highly desireable feature.
Two, we can add just enough EH support in C such that we can
drop the setjmp/longjmp solution and use EH alone for thread
cancelation. (Apparently the glibc folk consider building
libc with a C++ compiler to be an abomination. Given the
sometimes subtle differences between the two languages, I can't
really fault this point of view.)
> (One thing I've learned since the ABI discussions, by the way,
> is that asynchronous cancelation with pthread_cancel was only
> designed for some extremely specialized cases...
I'm talking about synchronous cancelation only.
r~