Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2008-05-08 10:15:20


"James Talbut" <James.Talbut_at_[hidden]> writes:

> The Windows docs do specify what happens with an uncaught exception:
> http://msdn.microsoft.com/en-us/library/ac9f67ah(VS.80).aspx
> And this document implies (very strongly, IMO) that this applies on any
> thread (given that it states that terminating the current thread is a
> viable option).
> Similarly the docs for set_terminate state that is operates on multiple
> threads: http://msdn.microsoft.com/en-us/library/t6fk7h29(VS.80).aspx

Those are the Microsoft compiler docs for Visual Studio 8. They don't apply to
e.g. Borland or gcc or Digital Mars compilers on Windows.

In the current working draft of C++0x, the terminate_handler passed to
set_terminate must still terminate execution of the program, even though
multiple threads are now permitted. If Microsoft continues to allow
termination of just that thread this is non-conforming.

> I know that I'm asking for a platform specific change, but the pain of
> this catch on Windows is quite significant.
>
> As a trivial example:
> DWORD WINAPI ThreadProc( LPVOID lpParameter )
> {
> throw 14;
> }
>
> void function()
> {
> throw 14;
> }
>
> int main(int argc, char * argv[])
> {
> // Comment out one or the other, so much easier than command line args
> CreateThread( NULL, 0, ThreadProc, NULL, 0, NULL );
> //boost::thread t( function );
>
> Sleep( 1000000 );
> }
>
>
> With the native call I get straight into the JIT handler, and windbg can
> report the line calling "throw 14".
> With the boost::thread call I get told that the application has
> requested that it be terminated in an unusual way - and the debugger
> knows nothing about my exception.

I agree that this can be useful, but you could always run your app in a
debugger and trap exceptions, or add a SEH filter to the top-level thread
function to trigger the debugger.

Anthony

-- 
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

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