Re: [Boost-bugs] [Boost C++ Libraries] #7861: lockfree freelist doesn't destruct objects until its destructor is called

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7861: lockfree freelist doesn't destruct objects until its destructor is called
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-01-07 10:12:52


#7861: lockfree freelist doesn't destruct objects until its destructor is called
-----------------------------------+----------------------------------------
  Reporter: toffaletti@… | Owner: timblechmann
      Type: Bugs | Status: reopened
 Milestone: To Be Determined | Component: lockfree
   Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords:
-----------------------------------+----------------------------------------
Changes (by anonymous):

  * status: closed => reopened
  * resolution: invalid =>

Comment:

 Reopening because I've got a few questions about your response. True my
 code had a race condition, but the original code I was trying to distill
 did not. Here is a version without a race condition that still has the
 leak:

 {{{
 #include <boost/lockfree/queue.hpp>
 #include <memory>
 #include <vector>
 #include <thread>
 #include <atomic>

 static std::atomic<uint64_t> count{0};

 struct LeakFinder {
     LeakFinder() {
         ++count;
     }

     ~LeakFinder() {
         --count;
     }
 };

 static boost::lockfree::queue<std::shared_ptr<LeakFinder>> queue(128);
 static bool done = false;

 void producer() {
     for (int i=0; i<1; ++i) {
         queue.push(std::make_shared<LeakFinder>());
     }
 }

 int main() {
     std::vector<std::thread> producer_threads;
     for (int i=0; i<1; ++i) {
         producer_threads.emplace_back(producer);
     }

     for (auto &t : producer_threads) {
         t.join();
     }

     {
         std::shared_ptr<LeakFinder> v;
         while (queue.pop(v));
     }

     std::cout << "leak: " << count << "\n";
 }
 }}}


 I didn't see anything in the documentation that says queue can only store
 POD types with trivial assignment and destructor. If that is the case it
 should be noted and use static_assert to make it a compile time error.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7861#comment:2>
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:11 UTC