Boost Throws an exception on termination of the program

Forum for development in the C++ programming language.

Boost Throws an exception on termination of the program

Postby rob » 30 Oct 2014, 14:02

Hi

I receive the following error:

terminate called after throwing an instance of 'boost::exception_detail::clone_i
mpl<boost::exception_detail::error_info_injector<boost::system::system_error> >'

what(): close: An operation was attempted on something that is not a socket


when I call:

Code: Select all
MyGaze::~MyGaze()
{
    m_api.remove_listener( *this );
    m_api.disconnect();
}


More precisely this is where the exception is thrown:
in gazeapi_socket.cpp
Code: Select all
 Socket::~Socket()
    {
        if (m_thread.joinable())
        {
            m_thread.join();
        }
    }



----------

I guess one of the threads is still live after the socket is destroyed and tries to use it.

Has anyone faced such a problem? any solutions??!!!

//
I used the sdk in the GitHub and the example in the devs (http://dev.theeyetribe.com/cpp/) page.
I use Qt's MinGW to build the project.
rob
 
Posts: 1
Joined: 18 Dec 2013, 12:52

Re: Boost Throws an exception on termination of the program

Postby greg » 30 Oct 2014, 17:30

I added some code to the Socket::disconnect function to catch this exception:

Code: Select all
    void Socket::disconnect()
    {
        if (m_socket.is_open())
        {
         try
         {
            //gjb why was this commented out?
            m_socket.shutdown(boost::asio::socket_base::shutdown_type::shutdown_both);
            m_socket.close();
         }
         catch(boost::system::system_error e)
         {
            fprintf(stderr, "socket close caught error %d\n", e.code());
         }
         catch(std::exception e)
         {
            fprintf(stderr, "socket close caught NON BOOST error %s\n", e.what());
         }
         catch(...)
         {
            fprintf(stderr, "socket close caught some unknown kind of exception\n");
         }
        }

        m_io_service.stop(); // stops io_service and exits thread
    }

greg
 
Posts: 19
Joined: 19 Mar 2014, 21:05

Re: Boost Throws an exception on termination of the program

Postby Martin » 07 Nov 2014, 00:56

We are working on the disconnect issue with the C++ lib and hope to have a fix out soon.
Martin
 
Posts: 567
Joined: 29 Oct 2013, 15:20

Re: Boost Throws an exception on termination of the program

Postby zarachbaal » 27 Apr 2015, 10:15

Hi,
I'm having the same problems.
I work on Visual Studio 2008, it compiles well but when I run my project, ot crashes because of an unhandled exception :

terminate called after throwing an instance of 'boost::exception_detail::clone_i
mpl<boost::exception_detail::error_info_injector<boost::system::system_error> >'


The line the run stops at is in file "gazeapi.cpp" :

Code: Select all
void start()
{
    stop();
    m_thread = boost::thread( boost::bind( &Heartbeater::run, this))
}


I would like to know when will this problem be fixed ?
And if there is any way to make the sample run well ?

Regards,
zarachbaal
 
Posts: 3
Joined: 23 Apr 2015, 14:56


Return to C++