Opened 11 years ago
Closed 6 years ago
#6277 closed Bugs (fixed)
Checked iterators are not threadsafe
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | circular_buffer |
Version: | Boost 1.46.1 | Severity: | Problem |
Keywords: | Cc: |
Description
I encountered a problem whereby I was using the copy constructor of boost::circular_buffer in multiple threads. The attached code demonstrates the problem. The problem appears to be caused by the checked iterators, so does not occur in release builds.
Actual behaviour: Segmentation fault.
Expected behaviour: Program should loop indefinitely.
Workaround: #define BOOST_CB_DISABLE_DEBUG
Compilers tested: g++ 4.6.1 Visual C++ 2010 (cl.exe 16.00)
Platforms tested: x86_64-linux-gnu (Ubuntu 11.04) Windows 7 x64
Boost versions tested: Linux 1.46.1.1 (Ubuntu) Linux 1.48.0 Windows 1.46.1
Attachments (1)
Change History (9)
by , 11 years ago
follow-up: 2 comment:1 by , 9 years ago
No library is thread-safe until it is stated explicitly. Where this is on the documentation?
comment:2 by , 9 years ago
Replying to viboes:
No library is thread-safe until it is stated explicitly. Where this is on the documentation?
Here: http://www.boost.org/doc/libs/1_53_0/libs/circular_buffer/doc/circular_buffer.html#threadsafety
"simultaneous read accesses to a shared circular_buffer are safe."
This is also a requirement for C++11.
comment:3 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Oh thanks for clarification. What do you think of removing this specific debug behavior?
// BOOST_CB_ENABLE_DEBUG: Debug support control. #if defined(NDEBUG) || defined(BOOST_CB_DISABLE_DEBUG) #define BOOST_CB_ENABLE_DEBUG 0 #else #define BOOST_CB_ENABLE_DEBUG 1 #endif
// Debug enable is disabled temporarily as the associated code is not thread safe? #undef BOOST_CB_ENABLE_DEBUG
follow-up: 5 comment:4 by , 9 years ago
Severity: | Showstopper → Problem |
---|
As there is a workaround this is not a Showstopper.
comment:5 by , 7 years ago
Replying to viboes:
As there is a workaround this is not a Showstopper.
Recently I spent more than a week chasing some bugs that ended up to be in this racy debug code of Boost Circular Buffer...
So at least if it is not considered as a show-stopper, the issue and the work-around should be explained in the documentation in sections "Thread-Safety" and "Debug Support" of http://www.boost.org/doc/libs/1_60_0/doc/html/circular_buffer/implementation.html
Besides this, this library is great! Thanks.
follow-up: 7 comment:6 by , 6 years ago
I've created a PR to fix this: https://github.com/boostorg/circular_buffer/pull/9.
comment:7 by , 6 years ago
Replying to andysem:
I've created a PR to fix this: https://github.com/boostorg/circular_buffer/pull/9.
Nice! I've tried your version in https://github.com/amd/triSYCL/commit/dd5adeb9d8954ebccf13b837e5a6d415752db490 and it works. So, for me, it looks ready to land.
Thank you for your fix of this 4 year old bug!
comment:8 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Code which demonstrates the bug