[Boost-bugs] [Boost C++ Libraries] #8685: lockfree spsc_queue iterator pop failure

Subject: [Boost-bugs] [Boost C++ Libraries] #8685: lockfree spsc_queue iterator pop failure
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-06-10 21:29:26


#8685: lockfree spsc_queue iterator pop failure
------------------------------+--------------------------
 Reporter: meyers@… | Owner: timblechmann
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: lockfree
  Version: Boost 1.53.0 | Severity: Problem
 Keywords: |
------------------------------+--------------------------
 In the case where the producer has populated with N items such that they
 wrap around the end of the ring buffer, and the consumer uses the pop()
 interface with an output iterator, the pop method splits the copying into
 two chunks.

 The problem is that both calls to std::copy use the same destination
 value.


 {{{
             size_t count0 = max_size - read_index;
             size_t count1 = avail - count0;

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

 What we see is pop() returns 2 (in the case where N == 2), but what's read
 is the last value added, then some old value which happened to be there
 from before. The N-1 value is lost.

 Should the second call to std::copy be:

 {{{
             std::copy(internal_buffer, internal_buffer + count1, it +
 count0);
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8685>
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