Boost logo

Boost :

Subject: Re: [boost] [Thread] Win32 exception handling
From: Chris Newbold (Chris.Newbold_at_[hidden])
Date: 2008-11-25 15:32:47


> From: boost-bounces_at_[hidden] [mailto:boost-
> bounces_at_[hidden]] On Behalf Of David Abrahams
> Sent: Tuesday, November 25, 2008 2:59 PM

> on Tue Nov 25 2008, Matt Gruenke <mgruenke-AT-intellivid.com> wrote:
>
> > Some compilers (certainly GCC) have the ability to preserve the
> > stackframe from the time it was thrown (!), for uncaught exceptions.
> > If you catch (...), then the destructors of all the locals will
> > execute and you'll lose some information that could be instrumental
> in
> > tracking down the cause of the exception.
>
> Right, that's essentially the MSVC/Win32 behavior I'm describing.

Now that I think this through fully, I too have often cursed "unnecessary" top-level catch(...) blocks for exactly the same reason: they often result in the loss of context for the exception.

> > The catch (...) is one of the reasons we don't use boost::thread. I
> > even filed a bug on it:
> >
> >
> http://sourceforge.net/tracker/index.php?func=detail&aid=1274707&group_
> id=7586&atid=357586
> >
>
> OK, great, a second data point. How do you feel about the fact that
> the
> upcoming standard requires the catch(...)?

It seems like they've left some wiggle room, though, by not specifying whether or not the stack is unwound or not. Ideally, it wouldn't be (best for diagnostics), but I don't know of any platform that simultaneously allows you to write catch(...) and _not_ lose the context...

-Chris


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