[corountine2/context] forced_unwind exception on Windows with TDM-GCC

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[corountine2/context] forced_unwind exception on Windows with TDM-GCC

Boost - Users mailing list

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,

 


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [corountine2/context] forced_unwind exception on Windows with TDM-GCC

Boost - Users mailing list
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
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [corountine2/context] forced_unwind exception on Windows with TDM-GCC

Boost - Users mailing list

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 Mail for Windows 10

 

From: [hidden email]
Sent: 2018
1214 14:44
To: [hidden email]
Cc: [hidden email]
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
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

 


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [corountine2/context] forced_unwind exception on Windows with TDM-GCC

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On 14/12/2018, Hao Jiang via Boost-users <[hidden email]> wrote:
> 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%28Targetting%20Win32%20and%20Win64%29/ray_linn/gcc-8.x-with-ada/
, 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*
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [corountine2/context] forced_unwind exception on Windows with TDM-GCC

Boost - Users mailing list

Quite the whole project is built upon gcc, keep it portable among Windows, Linux and anther devices.

 

 

From: [hidden email]
Sent: 2018
1215 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 <[hidden email]> wrote:
> 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%28Targetting%20Win32%20and%20Win64%29/ray_linn/gcc-8.x-with-ada/
, 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*

 


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users