Skip to content

Commit de92b8a

Browse files
committed
Disable memory poisoning in DisjointPool
ASan throws an error whenever the memory poison is called for the memory allocated on GPU: "AddressSanitizer: CHECK failed: asan_mapping.h:359 "((AddrIsInMem(p))) != (0)" (0x0, 0x0)". This commit disables poisoning.
1 parent 5af717e commit de92b8a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/pool/pool_disjoint.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
#include "utils_math.h"
3232
#include "utils_sanitizers.h"
3333

34+
// Temporary solution for disabling memory poisoning. This is needed because
35+
// AddressSanitizer does not support memory poisoning for GPU allocations.
36+
// More info: https://github.com/oneapi-src/unified-memory-framework/issues/634
37+
#define POISON_MEMORY 0
38+
3439
typedef struct umf_disjoint_pool_shared_limits_t {
3540
size_t MaxSize;
3641
std::atomic<size_t> TotalSize;
@@ -400,7 +405,9 @@ static void *memoryProviderAlloc(umf_memory_provider_handle_t hProvider,
400405
if (ret != UMF_RESULT_SUCCESS) {
401406
throw MemoryProviderError{ret};
402407
}
408+
#if POISON_MEMORY
403409
utils_annotate_memory_inaccessible(ptr, size);
410+
#endif
404411
return ptr;
405412
}
406413

@@ -822,7 +829,9 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) try {
822829
FromPool = false;
823830
if (Size > getParams().MaxPoolableSize) {
824831
Ptr = memoryProviderAlloc(getMemHandle(), Size);
832+
#if POISON_MEMORY
825833
utils_annotate_memory_undefined(Ptr, Size);
834+
#endif
826835
return Ptr;
827836
}
828837

@@ -839,7 +848,9 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) try {
839848
}
840849

841850
VALGRIND_DO_MEMPOOL_ALLOC(this, Ptr, Size);
851+
#if POISON_MEMORY
842852
utils_annotate_memory_undefined(Ptr, Bucket.getSize());
853+
#endif
843854

844855
return Ptr;
845856
} catch (MemoryProviderError &e) {
@@ -877,7 +888,9 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, size_t Alignment,
877888
FromPool = false;
878889
if (AlignedSize > getParams().MaxPoolableSize) {
879890
Ptr = memoryProviderAlloc(getMemHandle(), Size, Alignment);
891+
#if POISON_MEMORY
880892
utils_annotate_memory_undefined(Ptr, Size);
893+
#endif
881894
return Ptr;
882895
}
883896

@@ -894,8 +907,9 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, size_t Alignment,
894907
}
895908

896909
VALGRIND_DO_MEMPOOL_ALLOC(this, AlignPtrUp(Ptr, Alignment), Size);
910+
#if POISON_MEMORY
897911
utils_annotate_memory_undefined(AlignPtrUp(Ptr, Alignment), Size);
898-
912+
#endif
899913
return AlignPtrUp(Ptr, Alignment);
900914
} catch (MemoryProviderError &e) {
901915
umf::getPoolLastStatusRef<DisjointPool>() = e.code;
@@ -962,8 +976,9 @@ void DisjointPool::AllocImpl::deallocate(void *Ptr, bool &ToPool) {
962976
}
963977

964978
VALGRIND_DO_MEMPOOL_FREE(this, Ptr);
979+
#if POISON_MEMORY
965980
utils_annotate_memory_inaccessible(Ptr, Bucket.getSize());
966-
981+
#endif
967982
if (Bucket.getSize() <= Bucket.ChunkCutOff()) {
968983
Bucket.freeChunk(Ptr, Slab, ToPool);
969984
} else {

0 commit comments

Comments
 (0)