boost.context cause strange crash on certan WIN32 API
Hi, I was using Boost.Asio.Spawn happliy until I ported my project to windows. I got stange openssl crash. many debug days speeded and there was nothing wrong with openssl. Strange thing is, openssl didn't crash when used in normal code, unless I used them in asio stackful coroutine. Now I finnally find the root cause and make it 100% reproducible. here is the code that demostrade the crash: <code> boost::context::fcontext_t fcm,fc1; void f1(intptr_t) { HMODULE advapi = LoadLibrary(TEXT("advapi32")); // crash there FreeLibrary(advapi); boost::context::jump_fcontext(fc1, &fcm, 0); } std::thread([](){ boost::context::guarded_stack_allocator alloc; std::size_t size(8192); void* sp1(std::malloc(size)); fc1=boost::context::make_fcontext(sp1, size, f1); boost::context::jump_fcontext(&fcm, fc1, 0); }); </code> the context created in threads other that main thread, can't call certain APIs. If LoadLibrary get called by an context that created in thread, it will crash. 100% reproducible on WIN64 platform with MSVC2013. And nothing wrong on WIN32 !
unfortunately MS does not document all parts of TIB, so it might be that boost.context does not swap all required TIB-parts.
在 2014年11月28日 星期五 15:23:37,Oliver Kowalke 写道:
unfortunately MS does not document all parts of TIB, so it might be that boost.context does not swap all required TIB-parts.
if TIB changes from time to time, I would rather boost.coroutine can have an option that uses win32 Fiber API instead of boost.context As for ConvertThreadToFiber call, made it a pre-requirement. let user call this api before jumping to io_service::run ;)
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
microcai
-
Oliver Kowalke