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:
http://codepad.org/tuQedXI7 It works as expected on Linux producing
1
2
Caught Host not found (authoritative)

but on Windows it crashes with:
1
2
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 ( http://mxe.cc/ )
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 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54267 — 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 hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net