Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] program crashes from time to time when deleting unique_future<void>
From: Soderback, Johan (Johan.Soderback_at_[hidden])
Date: 2011-11-22 12:01:49


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_at_[hidden]]
Sent: den 21 november 2011 21:34
To: Soderback, Johan
Cc: boost-users_at_[hidden]
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" <Johan.Soderback_at_[hidden]> wrote :-
> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net