| 1 | // Demonstrates bug in boost::cb_details::debug_iterator_registry
|
|---|
| 2 | // The copy constructor of boost::circular_buffer appears to not be threadsafe
|
|---|
| 3 | // due to lack of thread safety in boost::cb_details::debug_iterator_registry.
|
|---|
| 4 | // Compile command: g++ cb.cpp -lboost_thread
|
|---|
| 5 |
|
|---|
| 6 | // Add this line to remove seg fault:
|
|---|
| 7 | // #define BOOST_CB_DISABLE_DEBUG
|
|---|
| 8 |
|
|---|
| 9 | #include <boost/thread.hpp>
|
|---|
| 10 | #include <boost/circular_buffer.hpp>
|
|---|
| 11 |
|
|---|
| 12 | boost::circular_buffer<char> data(4096);
|
|---|
| 13 |
|
|---|
| 14 | void thread_fn()
|
|---|
| 15 | {
|
|---|
| 16 | while(1)
|
|---|
| 17 | {
|
|---|
| 18 | boost::circular_buffer<char> c(data); // Seg fault in here
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | int main()
|
|---|
| 23 | {
|
|---|
| 24 | boost::thread t1(thread_fn);
|
|---|
| 25 | thread_fn();
|
|---|
| 26 | }
|
|---|