Boost Users :
Subject: Re: [Boost-users] [context] Crash in case of exception from a context
Date: 2015-03-11 03:33:35
Actually the exception never leaves the stack frame of the context,
because I have put a try catch block inside the context-function as it was
recommended. - If I got the docs right
Here is a small demo. This crashes from V2013 standard C++ unit test.
When I step on the exception throwing line (the exception type does not
matter) then I get the "First-chance exception at 0x71E026A2 (clr.dll) in
vstest.executionengine.x86.exe: 0x80000001: Not implemented (parameters:
0x00000001, 0x0644AC84)." exception and when I pass it to the system then
a lot of "0xC0000005: Access violation" exceptions.
I have also played around with the stack size, but it does not seem to
have any effect.
std::cout << "I am still ok" << std::endl;
throw int(42); // The crash occurs here
std::cout << "Greetings from context f1" << std::endl;
std::cout << "Never reach this" << std::endl;
std::cout << "Exception caught" << std::endl;
void* stackPointer1(stack1 + size);
boost::context::fcontext_t fcm, fc1;
fc1 = boost::context::make_fcontext(stackPointer1, size, f1);
std::cout << "Greetings from main thread stack" << std::endl;
boost::context::jump_fcontext(&fcm, fc1, 0);
From: Nat Goodspeed <nat_at_[hidden]>
To: "boost-users_at_[hidden]" <boost-users_at_[hidden]>,
Date: 10.03.2015 17:40
Subject: Re: [Boost-users] [context] Crash in case of exception
from a context
Sent by: "Boost-users" <boost-users-bounces_at_[hidden]>
On Tue, Mar 10, 2015 at 10:32 AM, <Tamas.Ruszkai_at_[hidden]>
> I use boost::context to implement cooperative multitasking. At the
> use boost 1.57 on Windows 7 with VisualStudio 2013.
> Everything works fine until I throw an exception from a context created
> This guy metioned in his blogpost, that this problem was solved in boost
> 1.53 ("Boost 1.53 has updated and fixed version of boost::context
> that addresses exactly this problem. "), but somehow I still have the
> thing in 1.57. Is there some special preprocessor flag (#define) that I
> to activate to get this fix?
That contradicts what the Boost 1.57 documentation itself says :
"Exceptions in context-function
If the context-function emits an exception, the behaviour is undefined.
context-function should wrap the code in a try/catch block."
Boost-users mailing list
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