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

Conversation

smaslov-intel
Copy link
Contributor

Signed-off-by: Sergey V Maslov [email protected]

@smaslov-intel smaslov-intel requested a review from againull April 5, 2021 23:49
// This is crucial for graceful handling of plugins that couldn't be
// loaded, e.g. due to missing native run-times.
//
(void)SetErrorMode(SEM_FAILCRITICALERRORS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we can do this since it modifies behavior of user application.
Could you please provide more information about the problems with handling plugins loading?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of various reasons (e.g. missing native RT installation) and depending on system setting a modal message box is displayed to the user (and application freezes):
image

Moreover this is the recommended usage: https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode:

Best practice is that all applications call the process-wide SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application.

To be less intrusive we could change the setting only for loading plugins, and restore back after plugins initialization.
Would you prefer that ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, there still be risk that it can affect a user if they have additional threads doing something non-SYCL related.
Can we have a toggle to disable setting this mode?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand if this is going to address hangs in automated testing, probably, it's better to update tests to set this mode. What happens with these errors when SetErrorMode(SEM_FAILCRITICALERRORS) is set?
The doc says:
Instead, the system sends the error to the calling process.
But it is not quite clear which function gets the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a toggle to disable setting this mode?

I think we absolutely want to unconditionally suppress message boxes during plugins loading. If we choose to only affect plugins initialization (by restoring back users settings afterwards) then we don't need a toggle.

But it is not quite clear which function gets the error.

I think it would be through https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror but I didn't try that (and wouldn't want to do it as a part of this PR).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please clarify what happens then if there is an error like missing ze_loader.dll if SetErrorMode(SEM_FAILCRITICALERRORS) is done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the LoadLibraryA returns NULL, and the Level-Zero plugin is not loaded, ignored

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romanovvlad , do you need more clarifications? can we merge it?

@romanovvlad romanovvlad merged commit 54ede40 into intel:sycl Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants