Subject: [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-06 22:39:40
#7861: lockfree freelist doesn't destruct objects until its destructor is called
----------------------------------+-----------------------------------------
Reporter: toffaletti@⦠| Owner: timblechmann
Type: Bugs | Status: new
Milestone: To Be Determined | Component: lockfree
Version: Boost 1.53.0 | Severity: Problem
Keywords: |
----------------------------------+-----------------------------------------
This code demonstrates the problem:
{{{
$ cat leak.cc
#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>());
}
}
void consumer() {
while (!done) {
std::shared_ptr<LeakFinder> v;
while (queue.pop(v));
}
}
int main() {
std::vector<std::thread> producer_threads;
std::vector<std::thread> consumer_threads;
for (int i=0; i<1; ++i) {
producer_threads.emplace_back(producer);
}
for (int i=0; i<1; ++i) {
consumer_threads.emplace_back(producer);
}
for (auto &t : producer_threads) {
t.join();
}
done = true;
for (auto &t : consumer_threads) {
t.join();
}
std::cout << "leak: " << count << "\n";
}
}}}
{{{
$ g++ -ggdb -std=c++11 -pthread -I/home/jason/boost-1.53/include leak.cc
$ ./a.out
leak: 2
}}}
I think destructors should be called when memory is added to freelist.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7861> 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