Opened 9 years ago

Last modified 8 years ago

#9439 new Bugs

boost::spawn core dump

Reported by: ybb198602@… Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

My program generate an core dump when I create 50000 coroutines.The number of coroutines is too big?

gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)

My program is: #include <boost/bind.hpp> #include <boost/asio/io_service.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/spawn.hpp> #include <boost/asio/steady_timer.hpp> #include <boost/asio/write.hpp> #include <iostream> #include <memory> #include <sys/time.h> #include <sys/resource.h> #include <unistd.h> using boost::asio::ip::tcp;

void do_echo(boost::asio::yield_context yield,

boost::asio::io_service *io_service) {

for (; ;) {

try {

tcp::socket sock(*io_service); tcp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1"), 19011); sock.async_connect(ep, yield); std::cout<< 1 <<std::endl ;

} catch (...) {

std::cout<<"test";

}

}

}

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

try {

boost::asio::io_service io_service; for (int i=0; i<50000; ++i) {

boost::asio::spawn(io_service, boost::bind(&do_echo, _1, &io_service));

} io_service.run();

} catch(...) {

std::cerr << "Exception:\n";

} return 0;

}

Attachments (1)

test_spawn.cpp (1.6 KB ) - added by 348944179@… 8 years ago.
success tested 500000 coroutines using boost 1.56.0

Download all attachments as: .zip

Change History (5)

comment:1 by viboes, 9 years ago

Component: Noneasio
Owner: set to chris_kohlhoff

comment:2 by Dmitry Kadashev <dkadashev@…>, 8 years ago

The same test program crashes for me too with gcc 4.9 and boost 1.55. Actually it reliably crashes even with 2000 coroutines, and sometimes crashes with 1000.

% gcc --version
gcc (Debian 4.9.0-7) 4.9.0

I think it has something to do with async_connect(), because in a larger program I was working on handling incoming connections seems to work fine, but when it comes to connecting to another server it crashes shortly. Disabling these connects and just serving client some static error response seems to prevent crashes.

comment:3 by Dmitry Kadashev <dkadashev@…>, 8 years ago

This doesn't seem to happen with boost 1.56 beta.

in reply to:  3 comment:4 by 348944179@…, 8 years ago

Replying to Dmitry Kadashev <dkadashev@…>:

This doesn't seem to happen with boost 1.56 beta.

Yes, since 1.56 500000 coroutines I tested; But before it, 40000 crash on my machine, even no socket(just using boost::asio::system_timer on each coroutine to sleep).

by 348944179@…, 8 years ago

Attachment: test_spawn.cpp added

success tested 500000 coroutines using boost 1.56.0

Note: See TracTickets for help on using tickets.