Boost logo

Boost Users :

Subject: Re: [Boost-users] Unable to catch exception using boost::asio
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-07-15 11:56:22


> I wrapped my call to run() in a try-catch, no luck, no exception appears
> to be being thrown by io_service.run().
>
> void CBaseWebServer::RunIoService()
> {
>        try
>        {
>                m_IoService.run();
>        }
>        catch ( ... )
>        {
>                cout << "Unhandled exception in RunIoService";
>        }
> }
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

That probably won't help. Notice that CBaseWebServer::RunIoService()
is not in the call stack at the point you're seeing the exception.
After looking at your callstack again, I believe you're throwing from
a destructor. In particular, notice in your callstack that you have
this:

26 ~ProtoBufStreamAdaptor() /home/noirs/workspace/myfile2.cpp:10
0x000000000042c6e5
25 CWebServer::HandleGetNeighbors()
/home/noirs/workspace/myfile3.cpp:215 0x000000000041d2d8

These appear to both be in your own code. My suspicion is that an
exception occurs in CWebServer::HandleGetNeighbors(), which causes it
to unwind the stack and execute destructors. In particular a
destructor for an object of type ProtoBufStreamAdaptor() is called,
and this destructor then throws another exception. At this point your
program will definitely terminate immediately.

First check the destructor of ProtoBufStreamAdaptor() to see why it's
throwing (destructors should _never_ throw under any circumstances),
and then check the code of CWebServer::HandleGetNeighbors() to find
the original error.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net