# Bug in ObjectPool::hasOutstandingAllocations() ?

I have a nodelet which publishes standard image messages, and some nodelets which process these images. Since I use nodelets and transmit the messages using shared pointers, I also use a lockfree::ObjectPool for the allocation of the messages.

My initial problem was that I experience crashes when I unload my nodelets, due to the release of the ObjectPool before all the image messages shared pointers have been released.

To prevent these crashes, I tried to wait a bit in the destructor of the image publisher nodelet, using ObjectPool::hasOutstandingAllocations() as a way to determine when I can safely release the pool. However, this did not solved the crashes, and after a few tests, it seems that the hasOutstandingAllocations() method is buggy.

The documentation states:

bool hasOutstandingAllocations () Returns whether or not this FreeList currently has any outstanding allocations.

However, the code is as follows:

00103    bool FreeList::hasOutstandingAllocations()
00104    {
00105       return alloc_count_.load() == 0;
00106    }


But I think it should be the following:

00103    bool FreeList::hasOutstandingAllocations()
00104    {
00105       return alloc_count_.load() > 0;
00106    }


Or am I mistaken ?

edit retag close merge delete