On Mon, 21 Nov 2011 16:40:04 +0000 "Soderback, Johan"
Hi,
I have a small example program that crashes from time to time. I would appreciate some help to understand why.
In function run() executed on the main thread I create a packaged_task (pt), put it in a queue (_q) and wait for it to get executed (fu.get()). In another thread the tasks are executed when the queue _q is populated. The task I'm running always throws/rethrows intentionally.
It results (from time to time) in an access violation when the unique_future, fu, is deleted. See the stack trace at the bottom.
Anybody see any flaws in this design?
I have tried 1.47.0 and 1.48.0, MSVC 2005.
Trying your example on vs2010 it crashes continuously - changing your throwf() function to the following appears to sort it - not quite sure why a simple throw fails though - or whether this was your problem under vs2005 void throwf() { try { BOOST_THROW_EXCEPTION(TheException()); } catch (boost::exception const & ) { boost::rethrow_exception( boost::current_exception() ); } } HTH Alex