Skip to content

Commit 54ede40

Browse files
[SYCL] Suppress modal error message box during plugins loading on Windows (intel#3493)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 8dbaa53 commit 54ede40

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sycl/source/detail/windows_pi.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@ namespace detail {
1818
namespace pi {
1919

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

2435
int unloadOsLibrary(void *Library) {

0 commit comments

Comments
 (0)