[corountine2/context] forced_unwind exception on Windows with TDM-GCC
Hello all, I am porting my program from Linux to Windows with boost coroutine2. I found 32bit program throwing boost::context::detail::forced_unwind every time when coroutine destructed. But 64bit program works like charm. terminate called after throwing an instance of 'boost::context::detail::forced_unwind' The program works well on Linux(Ubuntu). Then I tried the official example: typedef boost::coroutines2::coroutine<int> coro_t; coro_t::pull_type source( [&](coro_t::push_type& sink){ int first=1,second=1; sink(first); sink(second); for(int i=0;i<8;++i){ int third=first+second; first=second; second=third; sink(third); } }); for(auto i:source) std::cout << i << " "; Same thing happened. Platform: windows 7 64 bit Boost: 1.67/1.69 Compiler: TDM-GCC 5.1 64bit. Best,
On 14/12/2018 16:16, Hao Jiang wrote:
I am porting my program from Linux to Windows with boost coroutine2. I found 32bit program throwing boost::context::detail::forced_unwind every time when coroutine destructed. But 64bit program works like charm.
terminate called after throwing an instance of 'boost::context::detail::forced_unwind'
Are you trying to compile with exceptions disabled or something? forced_unwind is part of the internal plumbing of Boost.Context and can be thrown from any yield point when the coroutine is destroyed while suspended. It's required that this exception is not swallowed and the whole call stack between the yield point and the "outside" of the coroutine is not noexcept. Having said that, I would think that normally that particular example should run to completion and not leave the coroutine suspended, so I wouldn't expect that exception there. Have you checked whether perhaps some other error is occurring first and then being "covered up" by the unwind?
Hi Gavin, Thanks for offering the answer. First question, I have enabled the exception. -fno-exceptions will cause compiling error. Second, I don’t think any error had happened other than coroutine/context destruction. I even tried a very simple code: #include <iostream> #include "boost/coroutine2/all.hpp" using namespace boost::coroutines2; using namespace std; int main() { auto source = coroutine<int>::pull_type([](coroutine<int>::push_type& sink) { int a = 1; sink.operator()(10); }); cout << source.operator bool() << endl; source(); cout << source.operator bool() << endl; return 0; } forced_unwind was thrown as well. BTW, I have the following observation: 1. On Ubuntu 18.4 and windows 64-bit program (where program worked) and windows 32 bit(program cracked), I found force_unwind was all constructed and thrown during coroutine destruction(boost 1.67: fiber_fcontext.hpp:58). I believe boost handles the exception itself on Ubuntu and Windows 64-bit but leaves it unhandled on Windows 32, since my program never handles that exception and never defines noexcept. 2. When corountine2 destroyed, its state is complete | unwind (boost 1.67: push_control_block_cc.ipp:40). Br, Hao. Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10 From: Gavin Lambert via Boost-usersmailto:boost-users@lists.boost.org Sent: 2018年12月14日 14:44 To: boost-users@lists.boost.orgmailto:boost-users@lists.boost.org Cc: Gavin Lambertmailto:boost@mirality.co.nz Subject: Re: [Boost-users] [corountine2/context] forced_unwind exception on Windows with TDM-GCC On 14/12/2018 16:16, Hao Jiang wrote:
I am porting my program from Linux to Windows with boost coroutine2. I found 32bit program throwing boost::context::detail::forced_unwind every time when coroutine destructed. But 64bit program works like charm.
terminate called after throwing an instance of 'boost::context::detail::forced_unwind'
Are you trying to compile with exceptions disabled or something? forced_unwind is part of the internal plumbing of Boost.Context and can be thrown from any yield point when the coroutine is destroyed while suspended. It's required that this exception is not swallowed and the whole call stack between the yield point and the "outside" of the coroutine is not noexcept. Having said that, I would think that normally that particular example should run to completion and not leave the coroutine suspended, so I wouldn't expect that exception there. Have you checked whether perhaps some other error is occurring first and then being "covered up" by the unwind? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On 14/12/2018, Hao Jiang via Boost-users
Hello all,
I am porting my program from Linux to Windows with boost coroutine2.
Why don't you use MSVC or Clang/LLVM then [to do that]?
Platform: windows 7 64 bit Boost: 1.67/1.69 Compiler: TDM-GCC 5.1 64bit.
Iff you must go the MinGW(64) route, the tool chain you chose is not very up-to-date [could cause your problem?] and support/dev seems to have stopped. I suggest you give https://nuwen.net/ a spin, it is very complete [includes a.o. boost pre-built [for Haswell, last time I looked]]. What's also quite good [and very up-to-date, weekly builds] is http://www.equation.com/servlet/equation.cmd?fa=fortran , it includes gfortran [handy for building OpenBlas in case you need that, or download MKL from Intel instead]. Then there is this tool-chain https://sourceforge.net/projects/mingw-w64/files/Multilib%20Toolchains%28Tar... , you can use it to build 32 and 64 bit binaries [includes fortran and ada]. This tool chain has a problem with it's C++ library [thread] headers, though. For the latter problem a [mostly] complete fix is the be found here: https://github.com/meganz/mingw-std-threads . degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*
Quite the whole project is built upon gcc, keep it portable among Windows, Linux and anther devices.
From: degskimailto:degski@gmail.com
Sent: 2018年12月15日 14:41
Subject: Re: [Boost-users] [corountine2/context] forced_unwind exception on Windows with TDM-GCC
On 14/12/2018, Hao Jiang via Boost-users
Hello all,
I am porting my program from Linux to Windows with boost coroutine2.
Why don't you use MSVC or Clang/LLVM then [to do that]?
Platform: windows 7 64 bit Boost: 1.67/1.69 Compiler: TDM-GCC 5.1 64bit.
Iff you must go the MinGW(64) route, the tool chain you chose is not very up-to-date [could cause your problem?] and support/dev seems to have stopped. I suggest you give https://nuwen.net/ a spin, it is very complete [includes a.o. boost pre-built [for Haswell, last time I looked]]. What's also quite good [and very up-to-date, weekly builds] is http://www.equation.com/servlet/equation.cmd?fa=fortran , it includes gfortran [handy for building OpenBlas in case you need that, or download MKL from Intel instead]. Then there is this tool-chain https://sourceforge.net/projects/mingw-w64/files/Multilib%20Toolchains%28Tar... , you can use it to build 32 and 64 bit binaries [includes fortran and ada]. This tool chain has a problem with it's C++ library [thread] headers, though. For the latter problem a [mostly] complete fix is the be found here: https://github.com/meganz/mingw-std-threads . degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*
participants (3)
-
degski
-
Gavin Lambert
-
Hao Jiang