cpp-netlib / cpp-netlib

The C++ Network Library Project -- cross-platform, standards compliant networking library.
http://cpp-netlib.org/
Boost Software License 1.0
2k stars 426 forks source link

http_async_8bit_tcp_resolve with custom asio::io_service crashes #122

Closed brunonery closed 12 years ago

brunonery commented 12 years ago

The following program:


#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/network/protocol/http/client.hpp>

using namespace boost::network;
using namespace boost::network::http;

typedef basic_client<http::tags::http_async_8bit_tcp_resolve, 1, 1> kaclient;

void timer(const boost::system::error_code& /* e */,
           boost::asio::deadline_timer* t)
{
    kaclient::request request_("http://www.google.com/");
    kaclient client_(t->get_io_service());
    kaclient::response response_ = client_.get(request_);

    t->expires_at(t->expires_at() + boost::posix_time::seconds(1));
    t->async_wait(boost::bind(timer, boost::asio::placeholders::error, t));
}

int main()
{
    boost::asio::io_service ioService;

    boost::asio::deadline_timer t(ioService, boost::posix_time::seconds(1));
    t.async_wait(boost::bind(timer, boost::asio::placeholders::error, &t));

    ioService.run();

    return 0;
}

gives the following error when run:

a.out: /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr<T>::operator->() const [with T = boost::asio::io_service::strand]: Assertion `px != 0' failed.
Aborted

The backtrace from GDB is:


#0  0x00130416 in __kernel_vsyscall ()
#1  0x00315c8f in raise () from /lib/i386-linux-gnu/libc.so.6
#2  0x003192b5 in abort () from /lib/i386-linux-gnu/libc.so.6
#3  0x0030e826 in __assert_fail () from /lib/i386-linux-gnu/libc.so.6
#4  0x080762c5 in boost::shared_ptr<boost::asio::io_service::strand>::operator-> (this=0x81890c8) at /usr/include/boost/smart_ptr/shared_ptr.hpp:418
#5  0x080748cf in boost::network::http::policies::async_resolver<boost::network::http::tags::http_async_8bit_tcp_resolve>::resolve(boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)>) (this=0x8189098, resolver_=..., host=..., port=80, once_resolved=...) at cpp-netlib-0.9.4/boost/network/protocol/http/policies/async_resolver.hpp:60
#6  0x0807e3ed in boost::_mfi::mf4<void, boost::network::http::policies::async_resolver<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >::call<boost::network::http::async_connection_policy<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>*, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >, std::string const, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >(boost::network::http::async_connection_policy<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>*&, void const*, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short&, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)>&) const (this=0x8189710, u=@0x8189718, b1=..., b2=..., b3=@0xbfffea0c, b4=...) at /usr/include/boost/bind/mem_fn_template.hpp:497
#7  0x0807d5ff in boost::_mfi::mf4<void, boost::network::http::policies::async_resolver<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >::operator()<boost::network::http::async_connection_policy<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>*>(boost::network::http::async_connection_policy<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>*&, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)>) const (this=0x8189710, 
    u=@0x8189718, a1=..., a2=..., a3=80, a4=...) at /usr/include/boost/bind/mem_fn_template.hpp:512
#8  0x0807c2b4 in boost::_bi::list5<boost::_bi::value<boost::network::http::async_connection_policy<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>*>, boost::arg<1>, boost::arg<2>, boost::arg<3>, boost::arg<4> >::operator()<boost::_mfi::mf4<void, boost::network::http::policies::async_resolver<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >, boost::_bi::list4<boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string&, unsigned short&, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)>&> >(boost::_bi::type<void>, boost::_mfi::mf4<void, boost::network::http::policies::async_resolver<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >&, boost::_bi::list4<boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string&, unsigned short&, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)>&>&, int) (this=0x8189718, f=..., a=...) at /usr/include/boost/bind/bind.hpp:525
#9  0x0807afaa in boost::_bi::bind_t<void, boost::_mfi::mf4<void, boost::network::http::policies::async_resolver<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >, boost::_bi::list5<boost::_bi::value<boost::network::http::async_connection_policy<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>*>, boost::arg<1>, boost::arg<2>, boost::arg<3>, boost::arg<4> > >::operator()<boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >, std::string, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >(boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string&, unsigned short&, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)>&)
    (this=0x8189710, a1=..., a2=..., a3=@0xbfffeafc, a4=...) at /usr/include/boost/bind/bind_template.hpp:145
#10 0x08079963 in boost::detail::function::void_function_obj_invoker4<boost::_bi::bind_t<void, boost::_mfi::mf4<void, boost::network::http::policies::async_resolver<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string const&, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >, boost::_bi::list5<boost::_bi::value<boost::network::http::async_connection_policy<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>*>, boost::arg<1>, boost::arg<2>, boost::arg<3>, boost::arg<4> > >, void, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >::invoke(boost::detail::function::function_buffer&, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)>) (function_obj_ptr=..., a0=..., a1=..., a2=80, a3=...)
    at /usr/include/boost/function/function_template.hpp:153
#11 0x080852aa in boost::function4<void, boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)> >::operator()(boost::asio::ip::basic_resolver<boost::asio::ip::tcp, boost::asio::ip::resolver_service<boost::asio::ip::tcp> >&, std::string, unsigned short, boost::function<void (boost::system::error_code const&, std::pair<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >)>) const (this=0x818970c, a0=..., a1=..., a2=80, a3=...)
    at /usr/include/boost/function/function_template.hpp:1013
#12 0x0808168d in boost::network::http::impl::http_async_connection<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>::start(boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const&, std::string const&, bool, boost::function<void (boost::iterator_range<char const*> const&, boost::system::error_code const&)>) (this=0x8189298, request=..., method=..., get_body=true, callback=...)
    at cpp-netlib-0.9.4/boost/network/protocol/http/client/connection/async_normal.hpp:86
#13 0x08072f6a in boost::network::http::async_connection_policy<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>::connection_impl::send_request(std::string const&, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const&, bool, boost::function<void (boost::iterator_range<char const*> const&, boost::system::error_code const&)>) (this=0x8189260, method=..., request_=..., get_body=true, callback=...)
    at cpp-netlib-0.9.4/boost/network/protocol/http/policies/async_connection.hpp:49
#14 0x08071cc1 in boost::network::http::impl::async_client<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>::request_skeleton(boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const&, std::string const&, bool, boost::function<void (boost::iterator_range<char const*> const&, boost::system::error_code const&)>) (this=0x8189098, request_=..., method=..., get_body=true, callback=...)
    at cpp-netlib-0.9.4/boost/network/protocol/http/client/async_impl.hpp:88
#15 0x080708d3 in boost::network::http::basic_client_facade<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>::boost_param_default_56get<boost::network::http::basic_response<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::network::http::tag::request, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const>, boost::parameter::aux::empty_arg_list>, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const, boost::function<void (boost::iterator_range<char const*> const&, boost::system::error_code const&)> >(boost::network::http::basic_response<boost::network::http::tags::http_async_8bit_tcp_resolve> (*)(), boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::network::http::tag::request, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const>, boost::parameter::aux::empty_arg_list> const&, int, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const&, boost::function<void (boost::iterator_range<char const*> const&, boost::system::error_code const&)>&) (
    this=0xbfffeecc, args=..., request=..., body_handler=...) at cpp-netlib-0.9.4/boost/network/protocol/http/client/facade.hpp:57
#16 0x0806e58c in boost::network::http::basic_client_facade<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>::boost_param_default_56get<boost::network::http::basic_response<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::network::http::tag::request, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const>, boost::parameter::aux::empty_arg_list>, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const> (this=0xbfffeecc, args=..., request=...)
    at cpp-netlib-0.9.4/boost/network/protocol/http/client/facade.hpp:56
#17 0x0806ba26 in boost::network::http::basic_client_facade<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>::boost_param_default_56get<boost::network::http::basic_response<boost::network::http::tags::http_async_8bit_tcp_resolve>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::network::http::tag::request, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const>, boost::parameter::aux::empty_arg_list>, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const> (this=0xbfffeecc, args=..., request=...)
    at cpp-netlib-0.9.4/boost/network/protocol/http/client/facade.hpp:56
#18 0x080677a8 in boost::network::http::basic_client_facade<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>::boost_param_implget<boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::network::http::tag::request, boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> const>, boost::parameter::aux::empty_arg_list> > (this=0xbfffeecc, args=...)
    at cpp-netlib-0.9.4/boost/network/protocol/http/client/facade.hpp:56
#19 0x0806103f in boost::network::http::basic_client_facade<boost::network::http::tags::http_async_8bit_tcp_resolve, 1u, 1u>::get<boost::network::http::basic_request<boost::network::http::tags::http_async_8bit_tcp_resolve> > (this=0xbfffeecc, a0=...)
    at cpp-netlib-0.9.4/boost/network/protocol/http/client/facade.hpp:56
#20 0x08053723 in timer (t=0xbffff284) at async.cpp:20
#21 0x08078a91 in boost::_bi::list2<boost::arg<1> (*)(), boost::_bi::value<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*> >::operator()<void (*)(boost::system::error_code const&, boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*), boost::_bi::list1<boost::system::error_code const&> > (this=0xbffff0b4, f=@0xbffff0b0, a=...) at /usr/include/boost/bind/bind.hpp:313
#22 0x08076ddd in boost::_bi::bind_t<void, void (*)(boost::system::error_code const&, boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*), boost::_bi::list2<boost::arg<1> (*)(), boost::_bi::value<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*> > >::operator()<boost::system::error_code> (this=0xbffff0b0, a1=...) at /usr/include/boost/bind/bind_template.hpp:47
#23 0x08074eaf in boost::asio::detail::binder1<boost::_bi::bind_t<void, void (*)(boost::system::error_code const&, boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*), boost::_bi::list2<boost::arg<1> (*)(), boost::_bi::value<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*> > >, boost::system::error_code>::operator() (this=0xbffff0b0) at /usr/include/boost/asio/detail/bind_handler.hpp:40
#24 0x08073150 in boost::asio::asio_handler_invoke<boost::asio::detail::binder1<boost::_bi::bind_t<void, void (*)(boost::system::error_code const&, boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*), boost::_bi::list2<boost::arg<1> (*)(), boost::_bi::value<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*> > >, boost::system::error_code> > (function=...) at /usr/include/boost/asio/handler_invoke_hook.hpp:64
#25 0x08071e99 in boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder1<boost::_bi::bind_t<void, void (*)(boost::system::error_code const&, boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*), boost::_bi::list2<boost::arg<1> (*)(), boost::_bi::value<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*> > >, boost::system::error_code>, boost::_bi::bind_t<void, void (*)(boost::system::error_code const&, boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*), boost::_bi::list2<boost::arg<1> (*)(), boost::_bi::value<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*> > > > (function=..., context=...) at /usr/include/boost/asio/detail/handler_invoke_helpers.hpp:39
#26 0x08070ba4 in boost::asio::detail::wait_handler<boost::_bi::bind_t<void, void (*)(boost::system::error_code const&, boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*), boost::_bi::list2<boost::arg<1> (*)(), boost::_bi::value<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > >*> > > >::do_complete (owner=0x8188288, base=0x81883e0) at /usr/include/boost/asio/detail/wait_handler.hpp:64
#27 0x08055c77 in boost::asio::detail::task_io_service_operation::complete (this=0x81883e0, owner=...)
    at /usr/include/boost/asio/detail/task_io_service_operation.hpp:35
#28 0x08057346 in boost::asio::detail::task_io_service::do_one (this=0x8188288, lock=..., this_idle_thread=0xbffff1f4)
    at /usr/include/boost/asio/detail/impl/task_io_service.ipp:278
#29 0x08056fa3 in boost::asio::detail::task_io_service::run (this=0x8188288, ec=...) at /usr/include/boost/asio/detail/impl/task_io_service.ipp:130
#30 0x08057664 in boost::asio::io_service::run (this=0xbffff2a8) at /usr/include/boost/asio/impl/io_service.ipp:57
#31 0x08053942 in main () at async.cpp:36
deanberris commented 12 years ago

This is a bug in the client code -- the client object can already be destroyed by the time the callback is invoked because the client instance is in the body of the timer callback.

neobobkrause commented 12 years ago

Not a problem with client code.

I'm experiencing the same problem, though I'm compiling with gcc 4.2 on macosx. I've been able to fix the problem by hacking the 0.9.4 code. Specifically, there are two async_client constructors in async_impl.hpp. The problem appears to be that the constructor that accepts an io_service doesn't initialize the resolverstrand data member. Adding the following line to the body of that constructor fixed the problem for me...

      connection_base::resolver_strand_.reset(new
                boost::asio::io_service::strand(service_));

Hope this helps,

deanberris commented 12 years ago

Oh, okay. Can you submit a pull request to fix this? It might make sense to have a 0.9.5 to address these issues. I can start a branch if you're up for this.

On Tue, Oct 23, 2012 at 11:22 AM, neobobkrause notifications@github.comwrote:

Not a problem with client code.

I'm experiencing the same problem, though I'm compiling with gcc 4.2 on macosx. I've been able to fix the problem by hacking the 0.9.4 code. Specifically, there are two async_client constructors in async_impl.hpp. The problem appears to be that the constructor that accepts an io_service doesn't initialize the resolverstrand data member. Adding the following line to the body of that constructor fixed the problem for me...

  connection_base::resolver_strand_.reset(new
            boost::asio::io_service::strand(service_));

Hope this helps,

  • Bob

    — Reply to this email directly or view it on GitHubhttps://github.com/cpp-netlib/cpp-netlib/issues/122#issuecomment-9685838.

Dean Michael Berris | Software Engineer Google

neobobkrause commented 12 years ago

Sure. What's the tag?

deanberris commented 12 years ago

The branch is 0.9-devel on cpp-netlib/cpp-netlib. If you can send a pull request against that branch we can start the process of getting it released as 0.9.5.

On Tue, Oct 23, 2012 at 3:53 PM, neobobkrause notifications@github.comwrote:

Sure. What's the tag?

— Reply to this email directly or view it on GitHubhttps://github.com/cpp-netlib/cpp-netlib/issues/122#issuecomment-9690598.

Dean Michael Berris | Software Engineer Google