{"action":"created","issue":{"url":"https://api.github.com/repos/mxe/mxe/issues/1559","repository_url":"https://api.github.com/repos/mxe/mxe","labels_url":"https://api.github.com/repos/mxe/mxe/issues/1559/labels{/name}","comments_url":"https://api.github.com/repos/mxe/mxe/issues/1559/comments","events_url":"https://api.github.com/repos/mxe/mxe/issues/1559/events","html_url":"https://github.com/mxe/mxe/issues/1559","id":185845202,"number":1559,"title":"Can't catch Boost.Asio exceptions inside coroutines","user":{"login":"rkfg","id":184066,"avatar_url":"https://avatars.githubusercontent.com/u/184066?v=3","gravatar_id":"","url":"https://api.github.com/users/rkfg","html_url":"https://github.com/rkfg","followers_url":"https://api.github.com/users/rkfg/followers","following_url":"https://api.github.com/users/rkfg/following{/other_user}","gists_url":"https://api.github.com/users/rkfg/gists{/gist_id}","starred_url":"https://api.github.com/users/rkfg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkfg/subscriptions","organizations_url":"https://api.github.com/users/rkfg/orgs","repos_url":"https://api.github.com/users/rkfg/repos","events_url":"https://api.github.com/users/rkfg/events{/privacy}","received_events_url":"https://api.github.com/users/rkfg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-28T06:01:05Z","updated_at":"2016-10-29T00:33:10Z","closed_at":null,"body":"I've posted this to Boost and Boost.Asio mailing lists and they said it could be compiler's fault. So I repost here hoping someone would shed some light on the issue.\r\n\r\nI have this little example of Boost.Asio code:\r\n```cpp\r\n#include <iostream>\r\n#include <stdexcept>\r\n#include <boost/asio.hpp>\r\n#include <boost/asio/spawn.hpp>\r\n\r\nusing namespace std;\r\nusing namespace boost::asio;\r\nusing namespace boost::asio::ip;\r\n\r\nio_service iosrv;\r\n\r\nvoid test(yield_context yield) {\r\n\ttcp::socket m_socket(iosrv);\r\n\ttry {\r\n\t\tcout << \"1\" << endl;\r\n\t\ttcp::resolver resolver(iosrv);\r\n\t\tcout << \"2\" << endl;\r\n\t\tauto endpoints = resolver.async_resolve(tcp::resolver::query(\"nonexistingdomain.com\", \"1111\"), yield);\r\n\t\tcout << \"3\" << endl;\r\n\t\tasync_connect(m_socket, endpoints, yield);\r\n\t\tcout << \"4\" << endl;\r\n\t} catch (const exception& e) {\r\n\t\tcout << \"Caught \" << e.what() << endl;\r\n\t} catch (...) {\r\n\t\tcout << \"Caught whatever\" << endl;\r\n\t}\r\n\r\n}\r\n\r\nint main(int argc, char* argv[]) {\r\n\tstrand s(iosrv);\r\n\tspawn(s, test);\r\n\tiosrv.run();\r\n}\r\n```\r\n\r\nIt works as expected on Linux producing\r\n1\r\n2\r\nCaught Host not found (authoritative)\r\n\r\nbut on Windows it crashes with:\r\n1\r\n2\r\nterminate called after throwing an instance of 'boost::system::system_error' what():  Unknown error\r\n\r\nTested 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.\r\n\r\nI also tried to disable Asio's threads with #define BOOST_ASIO_DISABLE_THREADS but that resulted in Asio's inability to start a background thread for asynchronous name resolution (that exception is caught fine)."},"comment":{"url":"https://api.github.com/repos/mxe/mxe/issues/comments/257058881","html_url":"https://github.com/mxe/mxe/issues/1559#issuecomment-257058881","issue_url":"https://api.github.com/repos/mxe/mxe/issues/1559","id":257058881,"user":{"login":"starius","id":920155,"avatar_url":"https://avatars.githubusercontent.com/u/920155?v=3","gravatar_id":"","url":"https://api.github.com/users/starius","html_url":"https://github.com/starius","followers_url":"https://api.github.com/users/starius/followers","following_url":"https://api.github.com/users/starius/following{/other_user}","gists_url":"https://api.github.com/users/starius/gists{/gist_id}","starred_url":"https://api.github.com/users/starius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starius/subscriptions","organizations_url":"https://api.github.com/users/starius/orgs","repos_url":"https://api.github.com/users/starius/repos","events_url":"https://api.github.com/users/starius/events{/privacy}","received_events_url":"https://api.github.com/users/starius/received_events","type":"User","site_admin":false},"created_at":"2016-10-29T00:33:10Z","updated_at":"2016-10-29T00:33:10Z","body":"Same error with [boost 1.62](https://github.com/mxe/mxe/pull/1549)"}}
{"actor":{"display_login":"starius"}}