Skip to content

[SYCL] Check if PluginInitializeFunction is NULL before accessing it. #963

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
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
3 changes: 3 additions & 0 deletions sycl/source/detail/pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ bool bindPlugin(void *Library) {

decltype(::piPluginInit) *PluginInitializeFunction = (decltype(
&::piPluginInit))(getOsLibraryFuncAddress(Library, "piPluginInit"));
if (PluginInitializeFunction == nullptr)
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about returning some error code instead of just boolean from this function? By doing so, you can report better messages to the user (which might be helpful during debugging).

Right now I see at least two possible breakage points here:

  • failed to get piPluginInit address, i.e. PluginIintializeFunction == nullptr
    PluginInitializeFunction returned non-success error code, i.e. err != PI_SUCCESS

P.S. there is even TODO for this at line 92

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. But this is needed at multiple places.
Whole PI functionality currently is not debugging friendly.
Is it ok if it is taken as a separate patch? @smaslov-intel and @romanovvlad have been suggesting a similar change.


int err = PluginInitializeFunction(&PluginInformation);

// TODO: Compare Supported versions and check for backward compatibility.
Expand Down