1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[Support] Make asan poisoning for recyclers more aggressive by also poisoning the 'next' pointer.

llvm-svn: 300882
This commit is contained in:
Benjamin Kramer 2017-04-20 20:28:18 +00:00
parent 531768787a
commit b9f7c3b050
2 changed files with 4 additions and 6 deletions

View File

@ -47,22 +47,21 @@ template <class T, size_t Align = alignof(T)> class ArrayRecycler {
FreeList *Entry = Bucket[Idx];
if (!Entry)
return nullptr;
__asan_unpoison_memory_region(Entry, Capacity::get(Idx).getSize());
Bucket[Idx] = Entry->Next;
__msan_allocated_memory(Entry, Capacity::get(Idx).getSize());
__asan_unpoison_memory_region(Entry, Capacity::get(Idx).getSize());
return reinterpret_cast<T*>(Entry);
}
// Add an entry to the free list at Bucket[Idx].
void push(unsigned Idx, T *Ptr) {
assert(Ptr && "Cannot recycle NULL pointer");
__asan_poison_memory_region(Ptr, Capacity::get(Idx).getSize());
__asan_unpoison_memory_region(Ptr, sizeof(FreeList));
FreeList *Entry = reinterpret_cast<FreeList*>(Ptr);
if (Idx >= Bucket.size())
Bucket.resize(size_t(Idx) + 1);
Entry->Next = Bucket[Idx];
Bucket[Idx] = Entry;
__asan_poison_memory_region(Ptr, Capacity::get(Idx).getSize());
}
public:

View File

@ -42,17 +42,16 @@ class Recycler {
FreeNode *pop_val() {
auto *Val = FreeList;
__asan_unpoison_memory_region(Val, Size);
FreeList = FreeList->Next;
__msan_allocated_memory(Val, Size);
__asan_unpoison_memory_region(Val, Size);
return Val;
}
void push(FreeNode *N) {
__asan_poison_memory_region(N, Size);
__asan_unpoison_memory_region(N, sizeof(FreeNode));
N->Next = FreeList;
FreeList = N;
__asan_poison_memory_region(N, Size);
}
public: