Boost logo

Boost :

From: Scott McCaskill (scott_at_[hidden])
Date: 2001-08-23 09:45:20


You're assuming that use of catch(...) implies that the exception will
always be re-thrown, but this does not have to be the case and indeed a
library implementor cannot make that guarantee:

void thread_func()
{
    try
    {
        // do some stuff
    }
    catch (...)
    {
        // no re-throw == no thread cancellation
    }
}

So, thread cancellation is implemented this way, in order for it to be
robust the user must guarantee that something like the above never occurs.
If any libraries are being used for which the source is not available, this
isn't possible (unless you have complete trust in the library vendor, I
suppose, but have fun tracking down _that_ kind of bug!).

Now, you can certainly argue that not rethrowing after catch(...) is bad,
wrong, immoral, etc. etc. and you'd be right, but this weakness is still
there. As has been pointed out by others, a robust solution will almost
certainly require some changes to the language and/or abstract machine
model.

----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, August 23, 2001 9:14 AM
Subject: Re: [boost] Ending/canceling/suspending a thread (proposal)

> From: "Scott McCaskill" <scott_at_[hidden]>
> > > Opinions? This behavior (with one minor exception) is implementable
now,
> > at
> > > least on paper.
> > >
> >
> > I think this would be a great solution _if_ you could guarantee that it
> > could not be circumvented (i.e. by catch(...)). Unfortunately, you
can't
> > (today), so it's a fairly fragile solution and therefore of dubious
value.
>
> What do you mean by 'circumvented by catch(...)'? catch(...) should catch
> the exception - that's a feature:
>
> void f(mutex & m)
> {
> m.lock();
>
> try
> {
> g();
> }
> catch(...)
> {
> m.unlock();
> throw;
> }
>
> m.unlock();
> }
>
> --
> Peter Dimov
> Multi Media Ltd.
>
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk