Boost logo

Boost :

From: Slawomir Lisznianski (slisznianski_at_[hidden])
Date: 2005-08-19 10:47:44


Hello,

I find the catch(...) clause in the thread_proxy function (thread.cpp)
causing more harm than good. If exception "leaks" from a function
executing in the context of a thread, the thread silently goes away but
the application continues to operate as if nothing happend. I think, in
this instance, the library simply "does too much" by trying to do the
cleanup. As a user, I can always wrap the code in the catch-all, but
what I cannot change is the fact that when unhandled exception is
thrown, I will not see the function in the stack trace where the
exception originated.
 
Here is the proposed proxy, after trivial changes:

extern "C" {
#if defined(BOOST_HAS_WINTHREADS)
    unsigned __stdcall thread_proxy(void* param)
#elif defined(BOOST_HAS_PTHREADS)
        static void* thread_proxy(void* param)
#elif defined(BOOST_HAS_MPTASKS)
        static OSStatus thread_proxy(void* param)
#endif
    {
        thread_param* p = static_cast<thread_param*>(param);
        boost::function0<void> threadfunc = p->m_threadfunc;
        p->started();
        threadfunc();
#if defined(BOOST_HAS_WINTHREADS)
        on_thread_exit();
#endif
#if defined(BOOST_HAS_MPTASKS)
        ::boost::detail::thread_cleanup();
#endif
        return 0;
    }
}

Regards,
Slawomir


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