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.

void fException()
{
        std::cout << "I am still ok" << std::endl;
        throw int(42); // The crash occurs here
}

void f1(intptr_t)
{
        try
        {
                std::cout << "Greetings from context f1" << std::endl;
                fException();
                std::cout << "Never reach this" << std::endl;
        }
        catch (...)
        {
                std::cout << "Exception caught" << std::endl;
        }
}

void test()
{
        std::size_t size(512*1024);
        char* stack1((char*)std::malloc(size));
        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@lindenlab.com>
To:        "boost-users@lists.boost.org" <boost-users@lists.boost.org>,
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@lists.boost.org>




On Tue, Mar 10, 2015 at 10:32 AM,  <Tamas.Ruszkai@leica-geosystems.com> wrote:

> I use boost::context to implement cooperative multitasking. At the moment I
> use boost 1.57 on Windows 7 with VisualStudio 2013.
>
> Everything works fine until I throw an exception from a context created by
> "boost::context::make_fcontext(.......)".
>
> 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 library
> that addresses exactly this problem. "), but somehow I still have the same
> thing in 1.57. Is there some special preprocessor flag (#define) that I have
> to activate to get this fix?

That contradicts what the Boost 1.57 documentation itself says [0]:

"Exceptions in context-function
If the context-function emits an exception, the behaviour is undefined.

(!) Important
context-function should wrap the code in a try/catch block."

[0]
http://www.boost.org/doc/libs/1_57_0/libs/context/doc/html/context/context.html
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users