Commit 7cfbc254 authored by Haijun Zhu's avatar Haijun Zhu Committed by Facebook Github Bot

Fix race condition in fibers CacheManager

Summary:
The non-atomic field `inUse_` is protected by a lock in `getStackCache`, but not in `giveBack`. This
is a data race and it is caught by TSAN.

Reviewed By: yfeldblum

Differential Revision: D17109710

fbshipit-source-id: 7c0d5d948740516422efca0895a702566c804bb4
parent 7c8c8039
...@@ -272,6 +272,7 @@ class CacheManager { ...@@ -272,6 +272,7 @@ class CacheManager {
friend class StackCacheEntry; friend class StackCacheEntry;
void giveBack(std::unique_ptr<StackCache> /* stackCache_ */) { void giveBack(std::unique_ptr<StackCache> /* stackCache_ */) {
std::lock_guard<folly::SpinLock> lg(lock_);
assert(inUse_ > 0); assert(inUse_ > 0);
--inUse_; --inUse_;
/* Note: we can add a free list for each size bucket /* Note: we can add a free list for each size bucket
......
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