-
Notifications
You must be signed in to change notification settings - Fork 125
[DeviceSanitizer] Check out-of-bounds on sycl::local_accessor #1532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DeviceSanitizer] Check out-of-bounds on sycl::local_accessor #1532
Conversation
Hi @oneapi-src/unified-runtime-maintain, please review. |
struct KernelInfo { | ||
ur_kernel_handle_t Handle; | ||
|
||
ur_shared_mutex Mutex; | ||
// Need preserve the order of local arguments | ||
std::map<uint32_t, LocalArgsInfo> LocalArgs; | ||
|
||
explicit KernelInfo(ur_kernel_handle_t Kernel) : Handle(Kernel) { | ||
[[maybe_unused]] auto Result = | ||
context.urDdiTable.Kernel.pfnRetain(Kernel); | ||
assert(Result == UR_RESULT_SUCCESS); | ||
} | ||
|
||
~KernelInfo() { | ||
[[maybe_unused]] auto Result = | ||
context.urDdiTable.Kernel.pfnRelease(Handle); | ||
assert(Result == UR_RESULT_SUCCESS); | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: KernelInfo
related codes are duplicated with sycl::buffer PR #1533 (under review).
Kindly ping @oneapi-src/unified-runtime-maintain. Thanks very much! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks generally OK, but please have someone knowledgeable in the sanitizer review the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
struct LaunchInfo { | ||
uintptr_t PrivateShadowOffset = | ||
0; // don't move this field, we use it in AddressSanitizerPass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to help me better understand the above comment, can we move other fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you can reorder other fields except PrivateShadowOffset
, because we assume PrivateShadowOffset
is the first field in ASanPass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
…ccessor (#13503) UR: oneapi-src/unified-runtime#1532 To check sycl::local_accessor(aka, dynamic local memory), we need to extend a new argument in spir kernel, this is because: - ASan needs to know some size information of local buffer, like its size and size with redzone, so that it can poison its shadow memory - By using this new argument, we can also pass some per-launch information (that is, it is different in each launch of kernel). One obvious example is SanitizerReport, which saves the error message, so that we can store and print multiple error reports for one kernel with different arguments. Another example is the shadow memory of local memory, this should be different per-launch as well, since one kernel can be launched multiple times and executed in parallel. I named this argument as "__asan_launch", which is a pointer pointed to "LaunchInfo" structure and allocated it in shared USM. To make this pointer can be used in spir_func w/o extending their argument, I created a global external local memory (external, so that it can be shared with other translation units, and its instance is defined in libdevice), and save the "__asan_launch" into this local memory immediately at the entry of kernel. UR can't check the name of kernel arguments, so it can't know if the kernel has "__asan_launch". So I assume the "__asan_launch" is always there, and added a check to prevent DAE pass from removing it. --------- Co-authored-by: Maosu Zhao <maosu.zhao@intel.com> Co-authored-by: Kenneth Benzie (Benie) <k.benzie@codeplay.com>
LLVM: intel/llvm#13503