pthread_cancel and EH: let's try this again
David Abrahams
dave at boost-consulting.com
Fri Jul 15 12:16:52 UTC 2005
Dave Butenhof <david.butenhof at hp.com> writes:
> You can try to say that C frames using POSIX cleanup cannot be
> interleaved with C++ frames; and that C++ frames using C++ cancel cannot
> be interleaved with frames using POSIX cleanup. But that makes no
> conceivable sense, and in practice is an unreasonable and infeasible
> restriction. They have to interoperate. They have to be the same.
I'm sure I'm missing something important here, but I'm going to barrel
ahead with my misconceptions anyway so that someone will set me
straight.
It's currently *very common* to write C++ code that assumes C++
exceptions must not propagate across the boundary between C++ and
other languages. That is the status quo for many systems and
compilers. Many, many C programs are not written with embedded
thread cleanups, and IMO it's almost unreasonably hard for a C
program to register all the cleanups it would need to maintain
invariants, because C lacks the necessary language support. It's
typical that a C++ exception will be translated into something that
ordinary C code can understand in those cases. "Ordinary" error
handling is hard enough in C.
So it would seem to me that the rule that "C frames using POSIX
cleanup cannot be interleaved with C++ frames" is probably already
being followed in a great deal of code.
> There has to be ONE cancellation mechanism. It has to propagate and
> behave as an exception because there's a vast body of existing code in
> many languages that already provides cleanup mechanisms based on
> exceptions, and POSIX cancel cleanup can also be implemented as an
> exception.
Yeah, but there's also a vast body of existing code that for practical
reasons has to assume that exceptions can't propagate across language
boundaries, and so has put other mechanisms in place to handle that
situation.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the c++-pthreads
mailing list