Skip to content

[SYCL]: Suppress modal error message box on Windows #3493

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 1 commit into from
Apr 8, 2021
Merged
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
13 changes: 12 additions & 1 deletion sycl/source/detail/windows_pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ namespace detail {
namespace pi {

void *loadOsLibrary(const std::string &PluginPath) {
return (void *)LoadLibraryA(PluginPath.c_str());
// Tells the system to not display the critical-error-handler message box.
// Instead, the system sends the error to the calling process.
// This is crucial for graceful handling of plugins that couldn't be
// loaded, e.g. due to missing native run-times.
// TODO: add reporting in case of an error.
// NOTE: we restore the old mode to not affect user app behavior.
//
UINT SavedMode = SetErrorMode(SEM_FAILCRITICALERRORS);
auto Result = (void *)LoadLibraryA(PluginPath.c_str());
(void)SetErrorMode(SavedMode);

return Result;
}

int unloadOsLibrary(void *Library) {
Expand Down