Boost logo

Boost :

Subject: Re: [boost] [thread] thread_proxy's catch(...) destroys my stack info for unhandled exceptions
From: Roberto Gimenez (chilabot_at_[hidden])
Date: 2008-12-27 14:37:57


Dmitry Goncharov <dgoncharov <at> unison.com> writes:

>
> Your f1() and f2() are callback function. If such a callback function
> throws an exception the program should be terminated, since the os
> cannot handle the exception for you.
> That's reasonable to embrace callbacks like f1() with a catch all block
> and deal with the exception the way you want.
> E.g.
> void f1()
> {
> try { throw 1; }
> catch(...) {abort();} // Here is your core dump.
> }
>
> If everybody did that there would be no need for boost::thread to
> provide the catch all block.
>

If everybody did that then everybody would lose their stack info and won't
know where the unexpected exception occurred. Unfortunatelly where
this doesn't happen the try-catch(...)-terminate() is a better option, but
where this does happen then it is not. So I guess a macro flag or bool flag
whould be good, or directly relying on the programer to put the try-catch(...)
inside the callback if needed.


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