Boost logo

Boost Users :

Subject: [Boost-users] Can't catch Boost.Asio exceptions inside coroutines
From: Sergey Shpikin (rkfg_at_[hidden])
Date: 2016-10-25 09:37:10

I have this little example of Boost.Asio code: It works as expected on Linux producing
Caught Host not found (authoritative)

but on Windows it crashes with:
terminate called after throwing an instance of 'boost::system::system_error'
what(): Unknown error

Tested on Windows Server 2008, Windows 7 and Wine, everything is the
same. I'm compiling on Linux for Windows with MXE ( )
on GCC 4.9.4, Boost version is 1.60.0. I'm really stuck at this point
as nothing in Google looks a valid solution for the case and I already
have a working application on Linux but it crashes on any network
error on Windows.

On Windows coroutines prevent any exceptions from being caught when
the program is compiled with -O1/2/3 but they're caught with -O0 or
-Os (see — this is
about GCC on FreeBSD but the same seemingly applies to MinGW).
However, boost's own exceptions, like the aforementioned
boost::system::system_error, still can't be caught.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at