This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: catch(...) and forced unwind
- From: Mark Mitchell <mark at codesourcery dot com>
- To: David Abrahams <dave at boost-consulting dot com>
- Cc: Jason Merrill <jason at redhat dot com>, Matt Austern <austern at apple dot com>, Ulrich Drepper <drepper at redhat dot com>, gcc at gcc dot gnu dot org, Richard Henderson <rth at redhat dot com>, Nathan Myers <ncm at cantrip dot org>, Jakub Jelinek <jakub at redhat dot com>, wekempf at cox dot net, fjh at cs dot mu dot oz dot au, Benjamin Kosnik <bkoz at redhat dot com>
- Date: 17 Dec 2003 09:14:23 -0800
- Subject: Re: catch(...) and forced unwind
- Organization: CodeSourcery, LLC
- References: <xypwu91ofvf.fsf@miranda.boston.redhat.com> <ud6at1wvg.fsf@boost-consulting.com> <xypekv9nr9u.fsf@miranda.boston.redhat.com> <u65gkyhv4.fsf@boost-consulting.com> <20031214035909.GE2416@tofu.dreamhost.com> <xypk74xltaa.fsf@miranda.boston.redhat.com> <ullpdlksl.fsf@boost-consulting.com> <xyp1xr5lh5q.fsf@miranda.boston.redhat.com> <usmjlhryu.fsf@boost-consulting.com> <278A5A0A-3001-11D8-8564-00039390D9E0@apple.com> <usmjkbkb5.fsf@boost-consulting.com> <0BB52C3C-3009-11D8-8564-00039390D9E0@apple.com> <ud6aobfgy.fsf@boost-consulting.com> <A156A7B0-3012-11D8-8564-00039390D9E0@apple.com> <uu1409v32.fsf@boost-consulting.com> <xypd6aoi0zz.fsf@miranda.boston.redhat.com> <1071632782.3793.114.camel@minax.codesourcery.com> <u4qvz8zae.fsf@boost-consulting.com> <1071678864.4082.22.camel@minax.codesourcery.com> <u3cbjmlgc.fsf@boost-consulting.com>
> >
> > If, on the other hand, you let go of all references to the
> > thread_cancellation object, then you decided you do not want to be
> > cancelled at all.
>
> *This time*. Because by letting go of the cancellation object, you
> re-enable cancellation points. That's kind of an odd paradox isn't
> it?
Yes, that re-enables cancellation points. I don't know if that's an odd
paradox. :-)
> > the same problems come up with cooperating processes in the presence
> > of signals. A correct program, written for an environment without
> > SIGTERM, must be audited before being deployed in an environment
> > with SIGTERM.
>
> Yeah, but signals were fundamentally different from exceptions until
> the posix/c++ standard conflict about which functions can throw arose.
The point is that both SIGTERM and thread-cancellation are ways that
some external influence can try to make your thread of control
terminate. In both cases, you have to figure out what resources you
need to deallocate when that happens. Alternatively, in both cases, you
can block the external interrupt.
> > In one mode, the C++ thread sees a conforming C++ environment (i.e., one
> > in which "printf" never throws exceptions). Stack unwinding will not be
> > done in that environment, so if such a thread is cancelled, it will not
> > get a chance to clean up after itself.
>
> Y'know, I don't like that. It doesn't give people the choice to add
> explicit cancellation checks to a codebase while preserving the C++
> standard behavior of functions that don't throw. If I was trying to
> import some generally-threadsafe code to a threaded environment,
> looking for a few places where it's safe to throw cancellations would
> be my first strategy.
So, then, you would want to use the other mode. :)
--
Mark Mitchell <mark@codesourcery.com>
CodeSourcery, LLC