[cpp-threads] Re: Exception propogation across threads
Kevlin Henney
kevlin at curbralan.com
Wed Feb 21 22:09:21 GMT 2007
Paul E. McKenney <paulmck at linux.vnet.ibm.com> writes
>
>I am uncharacteristically with Hans on this one. ;-)
>
>Here is the scenario that I am concerned about:
>
>o A threaded "server" application with indefinite lifetime.
>
>o One of the threads encounters a bug that results in an
> exception.
>
>o The rest of the server sort of runs along, but with strange
> behavior due to the dead thread.
>
>Seems like it would be better to just kill the whole process.
Agreed. Therefore, register a handler that does this. Problem solved,
clearly and explicitly :-)
>If the
>developer would prefer to make the failure known at join() time, it is
>pretty easy to put in top-level exception handlers, right?
Actually, no it isn't: a top-level exception handler in the executing
thread will stop an exception in the thread, but it won't propagate it
across a join. You need plumbing to do this, hence the reason to favour
a model that takes this into account rather than one that is oblivious
to it.
The bias to date in considering a programming model for threads has been
to treat thread executors as launching functions and function objects,
all of which are reasonably entitled to throw exceptions. This point of
view more closely aligns with the idea that an exception that leaves a
function should not be in the business of killing a process by default,
which makes more sense for coarse-grained threading whose failure you
consider critical, and therefore need to make a special point of
highlighting.
I am concerned that making total process death the chosen behaviour
shows a default bias towards coarse-grained threading, just as we are
moving into the era of fine-grained threading. As I said before, killing
the whole process seems unnecessarily severe: feel free to consider it
an option, but we should avoid imposing what some (myself included)
might consider to be unreasonable defaults.
Kevlin
--
____________________________________________________________
Kevlin Henney phone: +44 117 942 2990
mailto:kevlin at curbralan.com mobile: +44 7801 073 508
http://www.curbralan.com fax: +44 870 052 2289
Curbralan: Consultancy + Training + Development + Review
____________________________________________________________
More information about the cpp-threads
mailing list