[llvm] r257388 - BumpPtrAllocator::Reset should also poison the first slab which doesn't get deallocated.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 11 13:28:04 PST 2016


Author: pete
Date: Mon Jan 11 15:28:03 2016
New Revision: 257388

URL: http://llvm.org/viewvc/llvm-project?rev=257388&view=rev
Log:
BumpPtrAllocator::Reset should also poison the first slab which doesn't get deallocated.

When asan is enabled, we poison slabs as we allocate them, and only unpoison the pieces
we need from the slab.

However, in Reset, we were failing to reset the state of the slab back to being poisoned.

Patch by b17 c0de.

Modified:
    llvm/trunk/include/llvm/Support/Allocator.h

Modified: llvm/trunk/include/llvm/Support/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=257388&r1=257387&r2=257388&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Allocator.h (original)
+++ llvm/trunk/include/llvm/Support/Allocator.h Mon Jan 11 15:28:03 2016
@@ -187,6 +187,7 @@ public:
   /// \brief Deallocate all but the current slab and reset the current pointer
   /// to the beginning of it, freeing all memory allocated so far.
   void Reset() {
+    // Deallocate all but the first slab, and deallocate all custom-sized slabs.
     DeallocateCustomSizedSlabs();
     CustomSizedSlabs.clear();
 
@@ -198,7 +199,7 @@ public:
     CurPtr = (char *)Slabs.front();
     End = CurPtr + SlabSize;
 
-    // Deallocate all but the first slab, and deallocate all custom-sized slabs.
+    __asan_poison_memory_region(*Slabs.begin(), computeSlabSize(0));
     DeallocateSlabs(std::next(Slabs.begin()), Slabs.end());
     Slabs.erase(std::next(Slabs.begin()), Slabs.end());
   }




More information about the llvm-commits mailing list