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:
parent
531768787a
commit
b9f7c3b050
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user