Boost C++ Libraries: Ticket #6277: Checked iterators are not threadsafe https://svn.boost.org/trac10/ticket/6277 <p> 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. </p> <p> Actual behaviour: Segmentation fault. </p> <p> Expected behaviour: Program should loop indefinitely. </p> <p> Workaround: #define BOOST_CB_DISABLE_DEBUG </p> <p> Compilers tested: g++ 4.6.1 Visual C++ 2010 (cl.exe 16.00) </p> <p> Platforms tested: x86_64-linux-gnu (Ubuntu 11.04) Windows 7 x64 </p> <p> Boost versions tested: Linux 1.46.1.1 (Ubuntu) Linux 1.48.0 Windows 1.46.1 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6277 Trac 1.4.3 internet@… Fri, 16 Dec 2011 10:33:24 GMT attachment set https://svn.boost.org/trac10/ticket/6277 https://svn.boost.org/trac10/ticket/6277 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">cb.cpp</span> </li> </ul> <p> Code which demonstrates the bug </p> Ticket viboes Tue, 21 May 2013 18:10:58 GMT <link>https://svn.boost.org/trac10/ticket/6277#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6277#comment:1</guid> <description> <p> No library is thread-safe until it is stated explicitly. Where this is on the documentation? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 22 May 2013 08:47:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6277#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6277#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6277#comment:1" title="Comment 1">viboes</a>: </p> <blockquote class="citation"> <p> No library is thread-safe until it is stated explicitly. Where this is on the documentation? </p> </blockquote> <p> Here: <a href="http://www.boost.org/doc/libs/1_53_0/libs/circular_buffer/doc/circular_buffer.html#threadsafety">http://www.boost.org/doc/libs/1_53_0/libs/circular_buffer/doc/circular_buffer.html#threadsafety</a> </p> <blockquote> <p> "simultaneous read accesses to a shared circular_buffer are safe." </p> </blockquote> <p> This is also a requirement for C++11. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 09 Jun 2013 21:11:42 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/6277#comment:3 https://svn.boost.org/trac10/ticket/6277#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Jan Gaspar</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Oh thanks for clarification. What do you think of removing this specific debug behavior? </p> <pre class="wiki">// 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 </pre><pre class="wiki">// Debug enable is disabled temporarily as the associated code is not thread safe? #undef BOOST_CB_ENABLE_DEBUG </pre> Ticket viboes Sun, 09 Jun 2013 21:15:45 GMT severity changed https://svn.boost.org/trac10/ticket/6277#comment:4 https://svn.boost.org/trac10/ticket/6277#comment:4 <ul> <li><strong>severity</strong> <span class="trac-field-old">Showstopper</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> As there is a workaround this is not a Showstopper. </p> Ticket ronan.keryell@… Fri, 29 Jan 2016 23:52:59 GMT <link>https://svn.boost.org/trac10/ticket/6277#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6277#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6277#comment:4" title="Comment 4">viboes</a>: </p> <blockquote class="citation"> <p> As there is a workaround this is not a Showstopper. </p> </blockquote> <p> Recently I spent more than a week chasing some bugs that ended up to be in this racy debug code of Boost Circular Buffer... </p> <p> 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 <a href="http://www.boost.org/doc/libs/1_60_0/doc/html/circular_buffer/implementation.html">http://www.boost.org/doc/libs/1_60_0/doc/html/circular_buffer/implementation.html</a> </p> <p> Besides this, this library is great! Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Thu, 28 Apr 2016 22:01:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6277#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6277#comment:6</guid> <description> <p> I've created a PR to fix this: <a class="ext-link" href="https://github.com/boostorg/circular_buffer/pull/9"><span class="icon">​</span>https://github.com/boostorg/circular_buffer/pull/9</a>. </p> </description> <category>Ticket</category> </item> <item> <author>ronan.keryell@…</author> <pubDate>Mon, 02 May 2016 08:24:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6277#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6277#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6277#comment:6" title="Comment 6">andysem</a>: </p> <blockquote class="citation"> <p> I've created a PR to fix this: <a class="ext-link" href="https://github.com/boostorg/circular_buffer/pull/9"><span class="icon">​</span>https://github.com/boostorg/circular_buffer/pull/9</a>. </p> </blockquote> <p> Nice! I've tried your version in <a class="ext-link" href="https://github.com/amd/triSYCL/commit/dd5adeb9d8954ebccf13b837e5a6d415752db490"><span class="icon">​</span>https://github.com/amd/triSYCL/commit/dd5adeb9d8954ebccf13b837e5a6d415752db490</a> and it works. So, for me, it looks ready to land. </p> <p> Thank you for your fix of this 4 year old bug! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Fri, 12 Aug 2016 04:57:56 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6277#comment:8 https://svn.boost.org/trac10/ticket/6277#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket