logging: add an assert for the FLAG_INHERIT bit
[folly.git] / folly / fibers / Fiber.cpp
index 79866600e2b7575a866a007b211fa5f058ccb74d..afc05200a878ee6b34ef491eb87721b29724eae4 100644 (file)
@@ -49,7 +49,7 @@ static size_t nonMagicInBytes(unsigned char* stackLimit, size_t stackSize) {
   return (end - firstNonMagic) * sizeof(uint64_t);
 }
 
-} // anonymous namespace
+} // namespace
 
 void Fiber::resume() {
   DCHECK_EQ(state_, AWAITING);
@@ -103,6 +103,9 @@ void Fiber::init(bool recordStackUsed) {
 
 Fiber::~Fiber() {
 #ifdef FOLLY_SANITIZE_ADDRESS
+  if (asanFakeStack_ != nullptr) {
+    fiberManager_.freeFakeStack(asanFakeStack_);
+  }
   fiberManager_.unpoisonFiberStack(this);
 #endif
   fiberManager_.stackAllocator_.deallocate(fiberStackLimit_, fiberStackSize_);
@@ -186,6 +189,10 @@ void Fiber::preempt(State state) {
   }
 }
 
+Fiber::LocalData::~LocalData() {
+  reset();
+}
+
 Fiber::LocalData::LocalData(const LocalData& other) : data_(nullptr) {
   *this = other;
 }
@@ -228,5 +235,5 @@ void* Fiber::LocalData::allocateHeapBuffer(size_t size) {
 void Fiber::LocalData::freeHeapBuffer(void* buffer) {
   delete[] reinterpret_cast<char*>(buffer);
 }
-}
-}
+} // namespace fibers
+} // namespace folly