AMDGPU.jl icon indicating copy to clipboard operation
AMDGPU.jl copied to clipboard

Assertion failure due to illegal implicit addrspacecast

Open maleadt opened this issue 11 months ago • 0 comments

With https://github.com/JuliaLang/julia/pull/53687, ExaTron.jl tests run into an assertion failure due to what I think is a bug in AMDGPU.jl. The problem lies with free!(AMDGPU.Device.HostCallHolder), which compiles the following ccall:

Expr(:foreigncall, Expr(:call, Core.tuple, :(:hipHostFree), AMDGPU.HIP.libhip), AMDGPU.HIP.hipError_t, svec(Ptr{Nothing}), 0, :(:ccall), SSAValue(7), SSAValue(7))

Here, hipHostFree is invoked with a Ptr{Nothing}) (i.e. addrspace(0)) pointer, however, HostCallHolder contains HostCall which results in passing a LLVMPtr{UInt8, AS.Global} (i.e. addrspace(1)) pointer. This kind of implicit address space conversion is illegal, and only happened to work because of the implicit ptrtoint/inttoptr that happened at the ccall boundary because of Julia storing pointers as i64. That is changing in https://github.com/JuliaLang/julia/pull/53687.

It seems like the HostCall struct shouldn't be used as such on the CPU, where it should simply use a Ptr instead.

maleadt avatar Mar 19 '24 08:03 maleadt