Re: [Boost-users] Initialization of boost::asio::ip::tcp::socket geneates unhandled exception

Hi, The problem is somewhere in the design of your program, so it's hardly possible to find out it from this short description. Sounds like dangling reference/pointer - probably, io_service was destroyed/not initialized yet? (remember that the members are initialized in the order of their definition) 2008/7/28, Jean-Sebastien Stoezel <js.stoezel@gmail.com>:
Hi,
I'm getting confused by the unhandled exception I get when initializing a TCP socket. This happens when the socket is instantiated and initialized with an IO service object, from the constructor of a class called CProcessor.
Here are the variables declaration, inside the class:
boost::asio::ip::tcp::socket m_Socket; boost::asio::io_service m_IoService;
Here is what the default constructor looks like for this class: CProcessor::CProcessor(void): m_Socket(m_IoService) {}
The exception is generated by this constructor, as soon as the m_Socket object is initialized.
The type of unhandled exception I got is as follow: "Unhandled exception at whatever in hatever.exe: 0xC0000005: Access violation reading location 0xcccccce0." The program breaks in win_mutex.hpp, at a line calling: ::EnterCriticalSection(&crit_section_);
I run VS9.
Any idea?!
Thanks, Jean _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi, Actually the io service was defined after the socket, thus the socket was initialized before io service had been created. Defining the io service before the socket in the class fixed this issue. Thanks! Jean On 7/28/08, Igor R <boost.lists@gmail.com> wrote:
Hi,
The problem is somewhere in the design of your program, so it's hardly possible to find out it from this short description. Sounds like dangling reference/pointer - probably, io_service was destroyed/not initialized yet? (remember that the members are initialized in the order of their definition)
2008/7/28, Jean-Sebastien Stoezel <js.stoezel@gmail.com>:
Hi,
I'm getting confused by the unhandled exception I get when initializing a TCP socket. This happens when the socket is instantiated and initialized with an IO service object, from the constructor of a class called CProcessor.
Here are the variables declaration, inside the class:
boost::asio::ip::tcp::socket m_Socket; boost::asio::io_service m_IoService;
Here is what the default constructor looks like for this class: CProcessor::CProcessor(void): m_Socket(m_IoService) {}
The exception is generated by this constructor, as soon as the m_Socket object is initialized.
The type of unhandled exception I got is as follow: "Unhandled exception at whatever in hatever.exe: 0xC0000005: Access violation reading location 0xcccccce0." The program breaks in win_mutex.hpp, at a line calling: ::EnterCriticalSection(&crit_section_);
I run VS9.
Any idea?!
Thanks, Jean _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Igor R
-
Jean-Sebastien Stoezel