Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9355: boost::coroutine crash in base<void>::pull_coroutine_base<void> with multiple threads
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-11-08 21:49:36
#9355: boost::coroutine crash in base<void>::pull_coroutine_base<void> with
multiple threads
-------------------------------+----------------------------------------
Reporter: craig@⦠| Owner: olli
Type: Bugs | Status: closed
Milestone: To Be Determined | Component: coroutine
Version: Boost 1.55.0 | Severity: Problem
Resolution: worksforme | Keywords: pull_coroutine_base; crash
-------------------------------+----------------------------------------
Comment (by craig@â¦):
I have tested the issue under vc2010 on a different system and can also
reproduce the issue. This system has a Intel Centrino 2 core and does not
experience the crash when only 2 threads are utilized. With 4 threads the
issue however occurs but due to whatever the cause may be this processor
will crash between 580-1120 executions of the program so is not a good
platform to find or test on. I will try and test an i5 4670 at the weekend
and see if it similar to the i7-3960 of the original system.
New code:
{{{
#include <queue>
#include <boost/atomic.hpp>
#include <boost/bind.hpp>
#include <boost/coroutine/all.hpp>
#include <boost/lockfree/queue.hpp>
#include <boost/thread.hpp>
typedef boost::coroutines::coroutine< void > coro_t;
static void foo( coro_t::push_type& yield, int i )
{}
struct Worker
{
boost::atomic< bool > done;
Worker() :
done( false)
{}
void operator()()
{
while ( ! done)
{
pending.consume_all( [&]( int i)
{
coro_t::pull_type( boost::bind( foo, _1, i) );
} );
}
}
boost::lockfree::queue< int, boost::lockfree::capacity< 1024 > >
pending;
};
int main( int argc, char * argv[])
{
const uint32_t kCount = 4;
Worker workers[kCount];
boost::thread threads[kCount];
for ( uint32_t i = 0; i < kCount; ++i )
threads[i] = boost::thread( boost::ref( workers[i]) );
for ( uint32_t i = 0; i < kCount; ++i )
workers[i].pending.push(i);
for ( uint32_t i = 0; i < kCount; ++i )
workers[i].done = true;
for ( uint32_t i = 0; i < kCount; ++i )
threads[i].join();
return EXIT_SUCCESS;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9355#comment:10> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:14 UTC