Skip to content

Commit 88f2156

Browse files
committed
fix crash
1 parent 0a916a1 commit 88f2156

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

source/loader/layers/sanitizer/asan_interceptor.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,18 @@ ur_result_t SanitizerInterceptor::prepareLaunch(
670670
auto KernelInfo = getKernelInfo(Kernel);
671671

672672
// Validate pointer arguments
673-
for (const auto &[ArgIndex, PtrPair] : KernelInfo->PointerArgs) {
674-
auto Ptr = PtrPair.first;
675-
if (auto ValidateResult = ValidateUSMPointer(
676-
Context, DeviceInfo->Handle, (uptr)Ptr)) {
677-
ReportInvalidKernelArgument(Kernel, ArgIndex, (uptr)Ptr,
678-
ValidateResult, PtrPair.second);
679-
exit(1);
673+
if (Options(logger).DetectKernelArguments) {
674+
for (const auto &[ArgIndex, PtrPair] : KernelInfo->PointerArgs) {
675+
auto Ptr = PtrPair.first;
676+
if (Ptr == nullptr) {
677+
continue;
678+
}
679+
if (auto ValidateResult = ValidateUSMPointer(
680+
Context, DeviceInfo->Handle, (uptr)Ptr)) {
681+
ReportInvalidKernelArgument(Kernel, ArgIndex, (uptr)Ptr,
682+
ValidateResult, PtrPair.second);
683+
exit(1);
684+
}
680685
}
681686
}
682687

source/loader/layers/sanitizer/asan_options.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct AsanOptions {
3838
uint32_t MaxQuarantineSizeMB = 0;
3939
bool DetectLocals = true;
4040
bool DetectPrivates = true;
41+
bool DetectKernelArguments = true;
4142

4243
private:
4344
AsanOptions(logger::Logger &logger) {
@@ -93,6 +94,7 @@ struct AsanOptions {
9394
SetBoolOption("debug", Debug);
9495
SetBoolOption("detect_locals", DetectLocals);
9596
SetBoolOption("detect_privates", DetectPrivates);
97+
SetBoolOption("detect_kernel_arguments", DetectKernelArguments);
9698

9799
auto KV = OptionsEnvMap->find("quarantine_size_mb");
98100
if (KV != OptionsEnvMap->end()) {

source/loader/layers/sanitizer/asan_validator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ValidateUSMResult ValidateUSMPointer(ur_context_handle_t Context,
5656
AllocInfo);
5757
}
5858

59-
if (!IsSameDevice(AllocInfo->Device, Device)) {
59+
if (AllocInfo->Device && !IsSameDevice(AllocInfo->Device, Device)) {
6060
return ValidateUSMResult::fail(ValidateUSMResult::BAD_DEVICE,
6161
AllocInfo);
6262
}

0 commit comments

Comments
 (0)