[Boost-bugs] [Boost C++ Libraries] #8628: 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)

Subject: [Boost-bugs] [Boost C++ Libraries] #8628: 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)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-05-29 00:40:33


#8628: 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)
-----------------------------------------------------------------+----------
 Reporter: Constantin Fishkin <constantin_fishkin@…> | Owner: timblechmann
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: lockfree
  Version: Boost 1.53.0 | Severity: Problem
 Keywords: spsc_queue |
-----------------------------------------------------------------+----------
 spsc_queue::pop(OutputIterator 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)

 The following code will fill dst array improperly if the queue's read
 pointer is bigger than the queue's write pointer:

 unsigned char* dst=new unsigned char[100];

 count=q.pop(dst);

 The bug caused by the code in spsc_queue.hpp:224:

 std::copy(internal_buffer+read_index, internal_buffer+max_size, it);

 std::copy(internal_buffer, internal_buffer+count1, it);

 It will copy the second fragment starting from the same point it copied
 the first ftagment. The problem can be fixed as:

 it=std::copy(internal_buffer+read_index, internal_buffer+max_size, it);

 std::copy(internal_buffer, internal_buffer+count1, it);

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8628>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC