Early return for invalid pointer queries
If a user queries the pointer info on an invalid pointer, hsaKmtQueryPointerInfo will return error or unknown pointer. The other fields in HsaPointerInfo are invalid, so we do not return them to the user. Also removing the assert and returning unknown pointer instead. As the assert will not trigger in release builds. hsaKmtQueryPointerInfo may also return unknown pointer for userptrs as they are not always tracked by thunk. Adjusting code to still treat these pointers as valid in this case. Change-Id: Idf5cd8b61cd532d31b072f449839d223369bb138
This commit is contained in:
@@ -777,8 +777,11 @@ hsa_status_t Runtime::PtrInfo(const void* ptr, hsa_amd_pointer_info_t* info, voi
|
||||
// We don't care if this returns an error code.
|
||||
// The type will be HSA_EXT_POINTER_TYPE_UNKNOWN if so.
|
||||
auto err = hsaKmtQueryPointerInfo(ptr, &thunkInfo);
|
||||
assert(((err == HSAKMT_STATUS_SUCCESS) || (thunkInfo.Type == HSA_POINTER_UNKNOWN)) &&
|
||||
"Thunk ptr info error and not type HSA_POINTER_UNKNOWN.");
|
||||
if (err != HSAKMT_STATUS_SUCCESS || thunkInfo.Type == HSA_POINTER_UNKNOWN) {
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->type = HSA_EXT_POINTER_TYPE_UNKNOWN;
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (returnListData) {
|
||||
assert(thunkInfo.NMappedNodes <= agents_by_node_.size() &&
|
||||
|
||||
Reference in New Issue
Block a user