Commit 85b4ece6 authored by Nitin Garg's avatar Nitin Garg Committed by Facebook Github Bot

Ensure recyle is done only once in IndexedMemPool.h

Summary:
localPush invoked in recycleIndex can end up looping more than once if it has to retry the update of head. When that happens, the onRecycle call will be made again which will call destructor on the object again if eagerRecycle is true.

Fixed it by making sure only the 1st pass of the loop will call onRecycle.

(Note: this ignores all push blocking failures!)

Reviewed By: nbronson

Differential Revision: D18752349

fbshipit-source-id: 27dcb5c7840f724bbd39f4dc0176e21095a22284
parent c5269bb3
......@@ -433,9 +433,13 @@ struct IndexedMemPool {
void localPush(AtomicStruct<TaggedPtr, Atom>& head, uint32_t idx) {
Slot& s = slot(idx);
TaggedPtr h = head.load(std::memory_order_acquire);
bool recycled = false;
while (true) {
s.localNext.store(h.idx, std::memory_order_release);
Traits::onRecycle(&slot(idx).elem);
if (!recycled) {
Traits::onRecycle(&slot(idx).elem);
recycled = true;
}
if (h.size() == LocalListLimit) {
// push will overflow local list, steal it instead
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment