[cpp-threads] Re: Exception propogation across threads

Paul E. McKenney paulmck at linux.vnet.ibm.com
Wed Feb 21 21:42:12 GMT 2007


On Wed, Feb 21, 2007 at 08:40:43PM +0000, Kevlin Henney wrote:
> "Boehm, Hans" <hans.boehm at hp.com> writes
> >>
> >>Unwind the stack, terminate the thread and throw some kind of
> >>unexpected thread-death exception in the joining thread. Less
> >>severe than (i) and (ii), less compiler magic or modification
> >>of exceptions needed than
> >>(iii) and (iv), and more usable than (v).
> >>
> >My recollection from the last discussion is that this has the (probably
> >fatal?) flaw that the join may not be executed until next month.  Thus
> >you could effectively be hiding the exception for a month.  Since it
> >escaped the thread, it was presumably not completely handled, so we are
> >now letting the application run in a bad state for a month, potentially
> >wreaking all sorts of havoc.
> 
> When I first implemented the model I described, I included the notion of 
> a handler being called for just this reason. This approach is mentioned 
> in N1883. Following completion of any registered handler the thread 
> would terminate. Any immediate and urgent business that needed to be 
> handled has been handled. OTOH, if a month is what it takes to then 
> join, then that could be considered either a feature or a fault of the 
> designed system in question ;->
> 
> >It seems to me that the best choice is essentialy (i), with enough
> >facilities to let libraries implement other policies as needed.
> 
> This still seems unnecessarily severe, and perhaps it should be viewed 
> the other way around? With the callback model I described, perhaps (vi) 
> is the better option, with a hook for other behaviour, such as (i)? It 
> would be harder to adopt (i) and then provide useful and portable 
> alternatives than to adopt (vi) (or indeed (iii) or (iv)) with this 
> refinement, accommodating sudden death or various stack options.

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.  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?

						Thanx, Paul



More information about the cpp-threads mailing list