[compiler-rt] [compiler-rt][asan] Add AMDGPU ASan support via HSA API interceptors. (PR #192240)

Amit Kumar Pandey via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 02:31:53 PDT 2026


================
@@ -249,11 +249,60 @@ void ReportDeadlySignal(const SignalContext &sig) {
 }
 
 void ReportDoubleFree(uptr addr, BufferedStackTrace *free_stack) {
+  // GPU-only vmem reservations (VmemGpuReserveTracker) are not backed by
----------------
ampandey-1995 wrote:

> General question, why can't we track GPU VMem? 

GPU-only VMem reservations ( done by `hsa_amd_vmem_address_reserve_align`)  dosen't allocate memory , it just reserves a virtual address range that is registered with KFD as device VA. It's the rocr equivalent of `[cuMemAddressReserve ](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1ge489256c107df2a07ddf96d80c86cd9b)` like an **mmap(PROT_NONE)**. The pointer is valid, but there are no host-writable pages behind it. Physical backing only shows up later via (hsa_amd_vmem_handle_create+hsa_vmem_map). If we route that through ASan allocator, writing AsanChunk header/redzones in front of user pointer segfaults, because that VA isn't host-writable.

>  I thought this Asan approach implicitly required unified memory so we could handle it the same way.

This isn't really tied to unified memory. The allocations that are unified/host-accessible such as pool allocations and NO_REGISTER reserves (like HIP managed/SVM) do go through the normal path and get ASan chunk metadata + redzones just like CPU heap. It's specifically the GPU-only address reservations that can't because they are mmap (PROT_NONE) regions.
 
Tested below with example where my VA range base address
```
>>> p/x va
$13 = 0x7ffff5740000
>>> p/x size
$14 = 0x10000
>>>  p/x (char*)va + size
$15 = 0x7ffff5750000

**info proc mappings result**

7ffff5740000-7ffff5750000 ---p 00000000 00:00 0
```


https://github.com/llvm/llvm-project/pull/192240


More information about the llvm-commits mailing list