Re: [Boost-users] [Thread] program crashes from time to time when deleting unique_future<void>
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
Thanx Alex,
It works but not when I have the boost::current_exception_diagnostic_information() call
in the throwf() as in my example.
void throwf()
{
try
{
BOOST_THROW_EXCEPTION(TheException());
}
catch (...)
{
boost::current_exception_diagnostic_information();
boost::rethrow_exception( boost::current_exception() ); // or just throw;
}
}
The plain throw version seems to work as well without it, the call certainly triggers something.
Anyway, any idea what could be wrong?
/Johan
-----Original Message-----
From: Alex Perry [mailto:Alex.Perry@smartlogic.com]
Sent: den 21 november 2011 21:34
To: Soderback, Johan
Cc: boost-users@lists.boost.org
Subject: RE: [Boost-users] [Thread] program crashes from time to time when deleting unique_future<void>
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 Please consider the environment before printing this e-mail. The contents of this e-mail message (including any attachments) are confidential to and are intended to be conveyed for the use of the recipient to whom it is addressed only. If you receive this transmission in error, please notify the sender of this immediately and delete the message from your system. Any distribution, reproduction or use of this message by someone other than recipient is not authorized and may be unlawful.
On Tue, Nov 22, 2011 at 9:01 AM, Soderback, Johan
Thanx Alex,
It works but not when I have the boost::current_exception_diagnostic_information() call in the throwf() as in my example.
void throwf() { try { BOOST_THROW_EXCEPTION(TheException()); } catch (...) { boost::current_exception_diagnostic_information(); boost::rethrow_exception( boost::current_exception() ); // or just throw; } }
The plain throw version seems to work as well without it, the call certainly triggers something. Anyway, any idea what could be wrong?
/Johan
Seems suspicious, probably a bug in boost::exception_ptr. I'll look into it as time permits. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
participants (3)
-
Alex Perry
-
Emil Dotchevski
-
Soderback, Johan