Boost C++ Libraries: Ticket #8629: spsc_queue::pop(OutputIterator it) improperly works with random-access iterators if the read pointer is bigger than the write pointer (stored data consists of 2 blocks) https://svn.boost.org/trac10/ticket/8629 <p> spsc_queue::pop(<a class="missing wiki">OutputIterator</a> it) method improperly works with random-access iterators if the queue's read pointer is bigger than the queue's write pointer (the queue's stored data consists of 2 blocks) </p> <p> The following code will fill dst array improperly if the queue's read pointer is bigger than the queue's write pointer: </p> <p> unsigned char* dst=new unsigned char<a class="changeset" href="https://svn.boost.org/trac10/changeset/100" title="*** empty log message *** ">[100]</a>; </p> <p> count=q.pop(dst); </p> <p> The bug caused by the code in spsc_queue.hpp:224: </p> <p> std::copy(internal_buffer+read_index, internal_buffer+max_size, it); </p> <p> std::copy(internal_buffer, internal_buffer+count1, it); </p> <p> It will copy the second fragment starting from the same point it copied the first ftagment. The problem can be fixed as: </p> <p> it=std::copy(internal_buffer+read_index, internal_buffer+max_size, it); </p> <p> std::copy(internal_buffer, internal_buffer+count1, it); </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8629 Trac 1.4.3 Constantin Fishkin <constantin_fishkin@…> Wed, 29 May 2013 00:45:11 GMT attachment set https://svn.boost.org/trac10/ticket/8629 https://svn.boost.org/trac10/ticket/8629 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cpp</span> </li> </ul> <p> test that demonstrates the bug </p> Ticket timblechmann Wed, 29 May 2013 06:31:46 GMT <link>https://svn.boost.org/trac10/ticket/8629#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8629#comment:1</guid> <description> <p> good point ... but can you upload a working test case? will have a look at the code this night ... </p> </description> <category>Ticket</category> </item> <item> <author>Constantin Fishkin <constantin_fishkin@…></author> <pubDate>Wed, 29 May 2013 11:37:43 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/8629 https://svn.boost.org/trac10/ticket/8629 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> this time proper file </p> Ticket Constantin Fishkin <constantin_fishkin@…> Wed, 29 May 2013 11:39:03 GMT <link>https://svn.boost.org/trac10/ticket/8629#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8629#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8629#comment:1" title="Comment 1">timblechmann</a>: </p> <blockquote class="citation"> <p> good point ... but can you upload a working test case? will have a look at the code this night ... </p> </blockquote> <p> Oops, sorry. Please have a look at test.cpp </p> </description> <category>Ticket</category> </item> <item> <dc:creator>timblechmann</dc:creator> <pubDate>Fri, 31 May 2013 07:58:17 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8629#comment:3 https://svn.boost.org/trac10/ticket/8629#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84571" title="lockfree: spsc-queue - correct dequeue to output iterator fixes #8629 ...">[84571]</a>) lockfree: spsc-queue - correct dequeue to output iterator </p> <p> fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8629" title="#8629: Bugs: spsc_queue::pop(OutputIterator it) improperly works with random-access ... (closed: fixed)">#8629</a> </p> <p> Signed-off-by: Tim Blechmann &lt;tim@…&gt; </p> Ticket