Modify

Ticket #6277 (assigned Bugs)

Opened 3 years ago

Last modified 21 months ago

Checked iterators are not threadsafe

Reported by: internet@… 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

cb.cpp Download (610 bytes) - added by internet@… 3 years ago.
Code which demonstrates the bug

Change History

Changed 3 years ago by internet@…

Code which demonstrates the bug

comment:1 follow-up: ↓ 2 Changed 22 months ago by viboes

No library is thread-safe until it is stated explicitly. Where this is on the documentation?

comment:2 in reply to: ↑ 1 Changed 22 months ago by anonymous

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 Changed 21 months ago by viboes

  • Owner changed from jano_gaspar to viboes
  • Status changed from new to 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
Last edited 21 months ago by viboes (previous) (diff)

comment:4 Changed 21 months ago by viboes

  • Severity changed from Showstopper to Problem

As there is a workaround this is not a Showstopper.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as assigned
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.