[c++-pthreads] What are the real issues?

Fergus Henderson fjh at cs.mu.oz.au
Thu Jan 8 03:52:42 UTC 2004


On 07-Jan-2004, Ted Baker <baker at cs.fsu.edu> wrote:
> [someone, I think it was Richard Henderson, wrote:]
> > The Itanium C++ ABI, which gcc adopted, made cancellation a special 
> > kind of exception, "forced unwinding", so that a thread can't just 
> > catch the cancellation exception and swallow it.  The idea was that a 
> 
> This "forced unwinding" sounds different from normal exception
> processing, since you cannot catch the exception.  How deeply is
> this embedded in the gcc C++ implementation?

As Richard Henderson explained, this uncatchable forced unwinding
(for longjmp_unwind() and thread cancellation) was originally proposed
and for a brief period was implemented in GCC, but was then removed.
In the current GCC implementation, if I understand things correctly,
all exceptions are catchable via the C++ catch-elipsis construct "catch
(...)".  The idea of uncatchable exceptions was dropped because it
conflicted with standard C++ semantics which say that any exception can
be caught.  Some existing C++ code uses this for cleanup handlers, e.g.

	acquire_resource()
	try {
		use_resource();
	} catch(...) {
		release_resource();
		throw;	/* rethrow the same exception */
	}
	release_resource();

and the people who argued that code like this was important
and should be preserved won out over the people who argued
that longjmp_unwind() and thread cancellation should be uncatchable.

> For example, with GNAT, the task abort exception is processed
> exactly like other exceptions.  The difference is pretty
> superficial in that tha parser does not allow handlers for abort
> in user code.

If my understanding of GCC is correct, the current situation with GCC
is the same.

> From what I've read here, and my own experience, it seems this is
> the right thing to do, provided:
> 
> 1) The only way to handle this new cancellation exception is via a
> new syntax.

Unfortunately that would conflict with standard C++ semantics, which
say that any exception can be caught and handled using the catch-elipsis
construct "catch (...)".

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "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 c++-pthreads mailing list