Possible MingW ASIO bug with Boost 1.35.0 g++ 4.2.1

Some ASIO test code is crashing in a way that I do not understand. GDB is unable to debug it (no stack available on crash) and the error is a rather obtuse "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." Test code which crashes: #include <boost/asio/ip/address.hpp> #include <iostream> int main() { std::cout << boost::asio::ip::address::from_string("1.1.2.3") << std::endl; } By changing the asio file included, the code no longer crashes: #include <boost/asio.hpp> #include <iostream> int main() { std::cout << boost::asio::ip::address::from_string("1.1.2.3") << std::endl; } This is windowsxp professional, gcc version 4.2.1-dw2. I'm unable to test this on Linux at the moment, so I do not know if it affects other platforms. -Jason -- http://emptycrate.com Games, Programming, Travel & other stuff

Jason Turner wrote:
Some ASIO test code is crashing in a way that I do not understand. GDB is unable to debug it (no stack available on crash) and the error is a rather obtuse "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information."
Test code which crashes:
#include <boost/asio/ip/address.hpp> #include <iostream>
int main() { std::cout << boost::asio::ip::address::from_string("1.1.2.3") << std::endl; }
This is probably due to winsock not being initialised automatically as it is supposed to. Does the following inclusion sequence make it work? #include <boost/asio/ip/address.hpp> #include <boost/asio/detail/winsock_init.hpp> ... If winsock is not initialised then from_string will fail with an exception, which you're not catching. Cheers, Chris

Yes, you are correct that it was an unhandled exception. I'm a bit disturbed that gdb was not cluing me into that. However, adding the line: #include <boost/asio/detail/winsock_init.hpp> Does not solve the problem. -Jason On Tue, Jul 1, 2008 at 6:28 AM, Christopher Kohlhoff <chris@kohlhoff.com> wrote:
Jason Turner wrote:
Some ASIO test code is crashing in a way that I do not understand. GDB is unable to debug it (no stack available on crash) and the error is a rather obtuse "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information."
Test code which crashes:
#include <boost/asio/ip/address.hpp> #include <iostream>
int main() { std::cout << boost::asio::ip::address::from_string("1.1.2.3") << std::endl; }
This is probably due to winsock not being initialised automatically as it is supposed to. Does the following inclusion sequence make it work?
#include <boost/asio/ip/address.hpp> #include <boost/asio/detail/winsock_init.hpp> ...
If winsock is not initialised then from_string will fail with an exception, which you're not catching.
Cheers, Chris
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- http://emptycrate.com Games, Programming, Travel & other stuff
participants (2)
-
Christopher Kohlhoff
-
Jason Turner