Opened 10 years ago

Last modified 10 years ago

#7275 new Bugs

SIGSEGV in boost::asio::connect when compiled with g++ -std=c++0x

Reported by: Alan Yuelkenbeck <ayuelkenbeck@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc:

Description

Works fine when not compiled with -std=c++0x. GCC v. 4.6.3 on ubuntu 12.04 Linking to static libboost_thread, libboost_system (1.50.0 release config) Does not matter if server code is listening or not.

Minimal reproducible code below:

int main(int argc, char *argv[]) {

boost::asio::io_service service;

using namespace boost::asio::ip;

tcp::resolver resolver(service); tcp::resolver::query query(tcp::v4(), "127.0.0.1", "50001"); tcp::resolver::iterator itr = resolver.resolve(query);

if (itr != tcp::resolver::iterator()) {

tcp::socket s(service); boost::asio::connect(s, itr); Segmentation Fault Here

}

}

Callstack:

#0 0x8054d6e boost::asio::detail::reactive_socket_service_base::close(this=0x16, impl=..., ec=...) (reactive_socket_service_base.ipp:103) #1 0x8058f1a boost::asio::stream_socket_service<boost::asio::ip::tcp>::close(this=0x2, impl=..., ec=...) (stream_socket_service.hpp:151) #2 0x80589d5 boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >::close(this=0xbffff318, ec=...) (basic_socket.hpp:339) #3 0x8058186 boost::asio::connect<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition>(s=..., begin=..., end=..., connect_condition=..., ec=...) (connect.hpp:120) #4 0x80578a5 boost::asio::connect<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >(s=..., begin=..., ec=...) (connect.hpp:56) #5 0x8056dd2 boost::asio::connect<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >(s=..., begin=...) (connect.hpp:47) #6 0x8052f41 main(argc=1, argv=0xbffff874) (main.cpp:27)

Thank you.

Change History (1)

in reply to:  description comment:1 by Alan Yuelkenbeck <ayuelkenbeck@…>, 10 years ago

Fixed the formatting

  • Works fine when not compiled with -std=c++0x.
  • GCC v. 4.6.3 on ubuntu 12.04
  • Linking to static libboost_thread, libboost_system (1.50.0 release config)
  • Does not matter if server code is listening or not.

Minimal reproducible code below:

int main(int argc, char *argv[])
{
    boost::asio::io_service service;

    using namespace boost::asio::ip;

    tcp::resolver resolver(service);
    tcp::resolver::query query(tcp::v4(), "127.0.0.1", "50001");
    tcp::resolver::iterator itr = resolver.resolve(query);

    if (itr != tcp::resolver::iterator())
    {
        tcp::socket s(service);
        boost::asio::connect(s, itr); // Segmentation Fault Here
    }
}

Callstack:

boost::asio::detail::reactive_socket_service_base::close(this=0x16, impl=..., ec=...) (reactive_socket_service_base.ipp:103)
boost::asio::stream_socket_service<boost::asio::ip::tcp>::close(this=0x2, impl=..., ec=...) (stream_socket_service.hpp:151)
boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >::close(this=0xbffff318, ec=...) (basic_socket.hpp:339)
boost::asio::connect<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition>(s=..., begin=..., end=..., connect_condition=..., ec=...) (connect.hpp:120)
boost::asio::connect<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >(s=..., begin=..., ec=...) (connect.hpp:56)
boost::asio::connect<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >(s=..., begin=...) (connect.hpp:47)
main(argc=1, argv=0xbffff874) (main.cpp:27)

Thank you.

Note: See TracTickets for help on using tickets.