Page 1 of 1

Boost Throws an exception on termination of the program

PostPosted: 30 Oct 2014, 14:02
by rob
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.

Re: Boost Throws an exception on termination of the program

PostPosted: 30 Oct 2014, 17:30
by greg
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
    }


Re: Boost Throws an exception on termination of the program

PostPosted: 07 Nov 2014, 00:56
by Martin
We are working on the disconnect issue with the C++ lib and hope to have a fix out soon.

Re: Boost Throws an exception on termination of the program

PostPosted: 27 Apr 2015, 10:15
by zarachbaal
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,