Skip to content

Commit ef7829e

Browse files
committed
Merge pull request #2569 from zhaomaosu/asan-only-warn-host-ptr
[DevASAN] Only report warning if passing host ptr to kernel
1 parent ffb83cc commit ef7829e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

source/loader/layers/sanitizer/asan/asan_interceptor.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,10 @@ ur_result_t AsanInterceptor::prepareLaunch(
721721
ContextInfo->Handle, DeviceInfo->Handle, (uptr)Ptr)) {
722722
ReportInvalidKernelArgument(Kernel, ArgIndex, (uptr)Ptr,
723723
ValidateResult, PtrPair.second);
724-
exitWithErrors();
724+
if (ValidateResult.Type !=
725+
ValidateUSMResult::MAYBE_HOST_POINTER) {
726+
exitWithErrors();
727+
}
725728
}
726729
}
727730
}
@@ -864,13 +867,15 @@ AsanInterceptor::findAllocInfoByAddress(uptr Address) {
864867
std::shared_lock<ur_shared_mutex> Guard(m_AllocationMapMutex);
865868
auto It = m_AllocationMap.upper_bound(Address);
866869
if (It == m_AllocationMap.begin()) {
867-
return std::optional<AllocationIterator>{};
870+
return std::nullopt;
868871
}
869872
--It;
870-
// Make sure we got the right AllocInfo
871-
assert(Address >= It->second->AllocBegin &&
872-
Address < It->second->AllocBegin + It->second->AllocSize &&
873-
"Wrong AllocInfo for the address");
873+
874+
// Maybe it's a host pointer
875+
if (Address < It->second->AllocBegin ||
876+
Address >= It->second->AllocBegin + It->second->AllocSize) {
877+
return std::nullopt;
878+
}
874879
return It;
875880
}
876881

0 commit comments

Comments
 (0)