diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index 9aea1021f9..3e55ff7251 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -778,6 +778,8 @@ hsa_status_t Runtime::PtrInfo(const void* ptr, hsa_amd_pointer_info_t* info, voi bool returnListData = ((alloc != nullptr) && (num_agents_accessible != nullptr) && (accessible != nullptr)); + bool allocation_map_entry_found = false; + { // memory_lock protects access to the NMappedNodes array and fragment user data since these may // change with calls to memory APIs. ScopedAcquire lock(&memory_lock_); @@ -827,10 +829,17 @@ hsa_status_t Runtime::PtrInfo(const void* ptr, hsa_amd_pointer_info_t* info, voi retInfo.hostBaseAddress = retInfo.agentBaseAddress; retInfo.sizeInBytes = fragment->second.size; retInfo.userData = fragment->second.user_ptr; + allocation_map_entry_found = true; } } } // end lock scope + // Return type UNKNOWN for released fragments. Do not report the underlying block info to users! + if ((!allocation_map_entry_found) && + ((retInfo.type == HSA_EXT_POINTER_TYPE_HSA) || (retInfo.type == HSA_EXT_POINTER_TYPE_IPC))) { + retInfo.type = HSA_EXT_POINTER_TYPE_UNKNOWN; + } + retInfo.size = Min(size_t(info->size), sizeof(hsa_amd_pointer_info_t)); // IPC and Graphics memory may come from a node that does not have an agent in this process.