BumpPtrAllocator::Reset should also poison the first slab which doesn't get deallocated.
authorPete Cooper <peter_cooper@apple.com>
Mon, 11 Jan 2016 21:28:03 +0000 (21:28 +0000)
committerPete Cooper <peter_cooper@apple.com>
Mon, 11 Jan 2016 21:28:03 +0000 (21:28 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257388 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Allocator.h

index c608736fa95616f74dd65341550140da53351614..043d823146091ef083f5d602602fbf7845e6dcf7 100644 (file)
@@ -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());
   }