Noticed this with bgp_xmpp_basic_test, but bug appears to be genuine and in production code as well
==1060== Thread 34:
==1060== Invalid read of size 8
==1060== at 0x1772765: WorkQueue<boost::intrusive_ptr<boost::statechart::event_base const> >::EnqueueInternal(boost::intrusive_ptr<boost::statechart::event_base const>) (queue_task.h:542)
==1060== by 0x176F3E0: WorkQueue<boost::intrusive_ptr<boost::statechart::event_base const> >::Enqueue(boost::intrusive_ptr<boost::statechart::event_base const>) (queue_task.h:304)
==1060== by 0x17562E3: XmppStateMachine::Enqueue(boost::statechart::event_base const&) (xmpp_state_machine.cc:1612)
==1060== by 0x17553DA: XmppStateMachine::OnEvent(SslSession*, xmsm::SslHandShakeResponse) (xmpp_state_machine.cc:1472)
==1060== by 0x17390C2: XmppConnection::ProcessSslHandShakeResponse(boost::intrusive_ptr<SslSession>, boost::system::error_code const&) (xmpp_connection.cc:335)
==1060== by 0x1779DA2: boost::_mfi::mf2<void, XmppConnection, boost::intrusive_ptr<SslSession>, boost::system::error_code const&>::operator()(XmppConnection*, boost::intrusive_ptr<SslSession>, boost::system::error_code const&) const (mem_fn_template.hpp:280)
==1060== by 0x17793F1: void boost::_bi::list3<boost::_bi::value<XmppConnection*>, boost::arg<1>, boost::arg<2> >::operator()<boost::_mfi::mf2<void, XmppConnection, boost::intrusive_ptr<SslSession>, boost::system::error_code const&>, boost::_bi::list2<boost::intrusive_ptr<SslSession>&, boost::system::error_code const&> >(boost::_bi::type<void>, boost::_mfi::mf2<void, XmppConnection, boost::intrusive_ptr<SslSession>, boost::system::error_code const&>&, boost::_bi::list2<boost::intrusive_ptr<SslSession>&, boost::system::error_code const&>&, int) (bind.hpp:392)
==1060== by 0x1777E3B: void boost::_bi::bind_t<void, boost::_mfi::mf2<void, XmppConnection, boost::intrusive_ptr<SslSession>, boost::system::error_code const&>, boost::_bi::list3<boost::_bi::value<XmppConnection*>, boost::arg<1>, boost::arg<2> > >::operator()<boost::intrusive_ptr<SslSession>, boost::system::error_code>(boost::intrusive_ptr<SslSession>&, boost::system::error_code const&) (bind_template.hpp:89)
==1060== by 0x17767A2: boost::detail::function::void_function_obj_invoker2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, XmppConnection, boost::intrusive_ptr<SslSession>, boost::system::error_code const&>, boost::_bi::list3<boost::_bi::value<XmppConnection*>, boost::arg<1>, boost::arg<2> > >, void, boost::intrusive_ptr<SslSession>, boost::system::error_code const&>::invoke(boost::detail::function::function_buffer&, boost::intrusive_ptr<SslSession>, boost::system::error_code const&) (function_template.hpp:153)
==1060== by 0x189591B: boost::function2<void, boost::intrusive_ptr<SslSession>, boost::system::error_code const&>::operator()(boost::intrusive_ptr<SslSession>, boost::system::error_code const&) const (function_template.hpp:767)
==1060== by 0x1893CA6: SslSession::SslHandShakeCallback(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&) (ssl_session.cc:141)
==1060== by 0x189A97E: void boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()>::operator()<void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list1<boost::system::error_code const&> >(boost::_bi::type<void>, void (*&)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list1<boost::system::error_code const&>&, int) (bind.hpp:392)
==1060== by 0x1899E69: void boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> >::operator()<boost::system::error_code>(boost::system::error_code const&) (bind_template.hpp:47)
==1060== by 0x1898788: void boost::asio::ssl::detail::handshake_op::call_handler<boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >(boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> >&, boost::system::error_code const&, unsigned long const&) const (handshake_op.hpp:54)
==1060== by 0x1897BB5: boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code, unsigned long, int) (io.hpp:273)
==1060== by 0x189E417: boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long>::operator()() (bind_handler.hpp:127)
==1060== by 0x189E125: void boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long> >(boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long>, ...) (handler_invoke_hook.hpp:64)
==1060== by 0x189DAEC: void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long>, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >(boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long>&, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> >&) (handler_invoke_helpers.hpp:37)
==1060== by 0x189D331: void boost::asio::ssl::detail::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long>, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >(boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long>&, boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >*) (io.hpp:317)
==1060== by 0x189C7EA: void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long>, boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > > >(boost::asio::detail::binder2<boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned long>&, boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > >&) (handler_invoke_helpers.hpp:37)
==1060== by 0x189BDB7: boost::asio::detail::reactive_socket_recv_op<boost::asio::mutable_buffers_1, boost::asio::ssl::detail::io_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ssl::detail::handshake_op, boost::_bi::bind_t<void, void (*)(boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)>, boost::intrusive_ptr<SslSession>, boost::system::error_code const&), boost::_bi::list3<boost::_bi::value<boost::function<void (boost::intrusive_ptr<SslSession>, boost::system::error_code const&)> >, boost::_bi::value<boost::intrusive_ptr<SslSession> >, boost::arg<1> (*)()> > > >::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) (reactive_socket_recv_op.hpp:110)
==1060== by 0x12F3301: boost::asio::detail::task_io_service_operation::complete(boost::asio::detail::task_io_service&, boost::system::error_code const&, unsigned long) (task_io_service_operation.hpp:37)
==1060== by 0x12F388C: boost::asio::detail::epoll_reactor::descriptor_state::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) (epoll_reactor.ipp:651)
==1060== by 0x12F3301: boost::asio::detail::task_io_service_operation::complete(boost::asio::detail::task_io_service&, boost::system::error_code const&, unsigned long) (task_io_service_operation.hpp:37)
==1060== by 0x1888AEA: boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service_thread_info&, boost::system::error_code const&) (task_io_service.ipp:384)
==1060== by 0x1888470: boost::asio::detail::task_io_service::run(boost::system::error_code&) (task_io_service.ipp:153)
==1060== by 0x1888F50: boost::asio::io_service::run(boost::system::error_code&) (io_service.ipp:66)
==1060== by 0x1886438: EventManager::Run() (event_manager.cc:32)
==1060== by 0x1057443: ServerThread::Run() (event_manager_test.h:26)
==1060== by 0x10574B1: ServerThread::ThreadRun(void*) (event_manager_test.h:32)
==1060== by 0x5B44181: start_thread (pthread_create.c:312)
==1060== by 0x6DB800C: clone (clone.S:111)
==1060== Address 0x160862d0 is 480 bytes inside a block of size 744 free'd
==1060== at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1060== by 0x1056F2B: XmppStateMachineTest::~XmppStateMachineTest() (bgp_server_test_util.h:344)
==1060== by 0x1749CD1: void boost::checked_delete<XmppStateMachine>(XmppStateMachine*) (checked_delete.hpp:34)
==1060== by 0x17496A8: boost::scoped_ptr<XmppStateMachine>::~scoped_ptr() (scoped_ptr.hpp:82)
==1060== by 0x1736BFE: XmppConnection::~XmppConnection() (xmpp_connection.cc:60)
==1060== by 0x173B881: XmppServerConnection::~XmppServerConnection() (xmpp_connection.cc:674)
==1060== by 0x173B99D: XmppServerConnection::~XmppServerConnection() (xmpp_connection.cc:679)
==1060== by 0x174941B: XmppServerConnection::DeleteActor::Destroy() (xmpp_connection.cc:654)
==1060== by 0x18CA025: LifetimeManager::DeleteExecutor(LifetimeManager::LifetimeActorRef) (lifetime.cc:229)
==1060== by 0x18CD793: boost::_mfi::mf1<bool, LifetimeManager, LifetimeManager::LifetimeActorRef>::operator()(LifetimeManager*, LifetimeManager::LifetimeActorRef) const (mem_fn_template.hpp:165)
==1060== by 0x18CD16F: bool boost::_bi::list2<boost::_bi::value<LifetimeManager*>, boost::arg<1> >::operator()<bool, boost::_mfi::mf1<bool, LifetimeManager, LifetimeManager::LifetimeActorRef>, boost::_bi::list1<LifetimeManager::LifetimeActorRef&> >(boost::_bi::type<bool>, boost::_mfi::mf1<bool, LifetimeManager, LifetimeManager::LifetimeActorRef>&, boost::_bi::list1<LifetimeManager::LifetimeActorRef&>&, long) (bind.hpp:303)
==1060== by 0x18CCB31: bool boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, LifetimeManager, LifetimeManager::LifetimeActorRef>, boost::_bi::list2<boost::_bi::value<LifetimeManager*>, boost::arg<1> > >::operator()<LifetimeManager::LifetimeActorRef>(LifetimeManager::LifetimeActorRef&) (bind_template.hpp:32)
==1060== by 0x18CC634: boost::detail::function::function_obj_invoker1<boost::_bi::bind_t<bool, boost::_mfi::mf1<bool, LifetimeManager, LifetimeManager::LifetimeActorRef>, boost::_bi::list2<boost::_bi::value<LifetimeManager*>, boost::arg<1> > >, bool, LifetimeManager::LifetimeActorRef>::invoke(boost::detail::function::function_buffer&, LifetimeManager::LifetimeActorRef) (function_template.hpp:132)
==1060== by 0x18CDE7C: boost::function1<bool, LifetimeManager::LifetimeActorRef>::operator()(LifetimeManager::LifetimeActorRef) const (function_template.hpp:767)
==1060== by 0x18CDAA9: QueueTaskRunner<LifetimeManager::LifetimeActorRef, WorkQueue<LifetimeManager::LifetimeActorRef> >::RunQueue() (queue_task.h:87)
==1060== by 0x18CD8CB: QueueTaskRunner<LifetimeManager::LifetimeActorRef, WorkQueue<LifetimeManager::LifetimeActorRef> >::Run() (queue_task.h:66)
==1060== by 0x18DD27A: TaskImpl::execute() (task.cc:254)
==1060== by 0x5D7AB39: ??? (in /usr/lib/libtbb.so.2)
==1060== by 0x5D76815: ??? (in /usr/lib/libtbb.so.2)
==1060== by 0x5D75F4A: ??? (in /usr/lib/libtbb.so.2)
==1060== by 0x5D720FE: ??? (in /usr/lib/libtbb.so.2)
==1060== by 0x5D722F8: ??? (in /usr/lib/libtbb.so.2)
==1060== by 0x5B44181: start_thread (pthread_create.c:312)
==1060== by 0x6DB800C: clone (clone.S:111)
==1060==
Review in progress for https:/ /review. opencontrail. org/31792
Submitter: Nipa Kumar (<email address hidden>)