Boost.Context: SIGSEGV when switch a thread within a catch block
Hi, I get SIGSEGV on macOS when I switch an execution_context from a catch block with one thread and than switch back with another thread. Segmentation fault happens in libc++abi.dylib`__cxa_end_catch Does anyone have any ideas, what it could be? Is it legal to switch thread under an excecution_context while it's within a catch block? A minimal example is here: #include <boost/context/all.hpp> #include <future> using Context = boost::context::execution_context<void>; Context Main(Context context) { try { throw std::runtime_error("123"); } catch (const std::exception& ex) { context = context(); } return context(); } int main() { Context context(&Main); context = context(); std::thread([&] { context = context(); }).join(); return 0; } I see the problem on macOS with clang++ but can't reproduce on a linux with g++. $ uname -ap Darwin air.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64 i386 $ clang++ --version Apple LLVM version 8.0.0 (clang-800.0.42.1) Target: x86_64-apple-darwin16.3.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin -- Thanks, Alexander Pronchenkov
not permitted - see http://www.boost.org/doc/libs/1_63_0/libs/context/doc/html/context/ecv2.html
Hi Oliver, Thanks for your relay. Do you mean this statement in the documentation? [image: [Important]]Important Do not jump from inside a catch block and then re-throw the exception in another execution context. It's a bit unclear for me because I don't re-throw the exception neither in one execution context nor in another. Do you know how to address this issue? Is it addressed in Boost.Coroutines2? In my case I play with a green-threads runtime and this limitation means that I can't use asynchronous operations within exception handlers. It looks artificial and also requires checks/modifications of the existing code to make it compatible. :( -- Thanks, Alexander Pronchenkov On Mon, 2 Jan 2017 at 08:31, Oliver Kowalke <oliver.kowalke@gmail.com> wrote:
not permitted - see http://www.boost.org/doc/libs/1_63_0/libs/context/doc/html/context/ecv2.html
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
you must no call jump-op inside a catch block - that means you can't use async-op handlers inside exception handler exceptions might be implemented using sj/lj - in general, exception handlers are handled/implemented in a special way.
Hi Oliver, I think it would make sense to slightly clarify the documentation: - Do not jump from inside a catch block and then re-throw the exception in another execution context. + Do not jump from inside a catch block. Otherwise it's a bit confusing because I don't re-throw exceptions in my case but the problem is here. Also, do you known whether it's safe to jump from inside of a try block? I'm asking because there is a not at https://docs.oracle.com/cd/E24457_01/html/E21991/bkahg.html that
... you must not longjmp into or out of a try-block or catch-block (directly or indirectly) ...
-- Thanks, Alexander Pronchenkov On 2 January 2017 at 10:09, Oliver Kowalke <oliver.kowalke@gmail.com> wrote:
you must no call jump-op inside a catch block - that means you can't use async-op handlers inside exception handler exceptions might be implemented using sj/lj - in general, exception handlers are handled/implemented in a special way.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Alexander G. Pronchenkov
-
Oliver Kowalke
-
Александр Пронченков