Skip to content

[DeviceMSAN] Fix e2e tests crashed on OpenCL CPU #18150

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

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libdevice/sanitizer/msan_rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ inline uptr __msan_get_shadow_pvc(uptr addr, uint32_t as) {
return GetMsanLaunchInfo->CleanShadow;
}

inline void __msan_exit() {
if (!GetMsanLaunchInfo->IsRecover)
__devicelib_exit();
}

} // namespace

#define MSAN_MAYBE_WARNING(type, size) \
Expand All @@ -225,6 +230,7 @@ inline uptr __msan_get_shadow_pvc(uptr addr, uint32_t as) {
return; \
if (UNLIKELY(s)) { \
__msan_report_error(size, file, line, func, o); \
__msan_exit(); \
} \
}

Expand All @@ -236,13 +242,19 @@ MSAN_MAYBE_WARNING(u64, 8)
DEVICE_EXTERN_C_NOINLINE void
__msan_warning(const char __SYCL_CONSTANT__ *file, uint32_t line,
const char __SYCL_CONSTANT__ *func) {
if (!GetMsanLaunchInfo)
return;
__msan_report_error(1, file, line, func);
__msan_exit();
}

DEVICE_EXTERN_C_NOINLINE void
__msan_warning_noreturn(const char __SYCL_CONSTANT__ *file, uint32_t line,
const char __SYCL_CONSTANT__ *func) {
if (!GetMsanLaunchInfo)
return;
__msan_internal_report_save(1, file, line, func, 0);
__msan_exit();
}

// For mapping detail, ref to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ ur_result_t MsanInterceptor::prepareLaunch(

LaunchInfo.Data.Host.DeviceTy = DeviceInfo->Type;
LaunchInfo.Data.Host.Debug = getContext()->Options.Debug ? 1 : 0;
LaunchInfo.Data.Host.IsRecover = getContext()->Options.Recover ? 1 : 0;

// Clean shadow
// Its content is always zero, and is used for unsupport memory types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void SanitizerOptions::Init(const std::string &EnvName,
Parser.ParseBool("print_stats", PrintStats);
Parser.ParseBool("detect_leaks", DetectLeaks);
Parser.ParseBool("halt_on_error", HaltOnError);
Parser.ParseBool("recover", Recover);

Parser.ParseUint64("quarantine_size_mb", MaxQuarantineSizeMB, 0, UINT32_MAX);
Parser.ParseUint64("redzone", MinRZSize, 16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct SanitizerOptions {
bool DetectKernelArguments = true;
bool DetectLeaks = true;
bool HaltOnError = true;
bool Recover = false;

void Init(const std::string &EnvName, logger::Logger &Logger);
};
Expand Down