Skip to content
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

Add check to early exit when OpenCL builtin is not found in the map #2525

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

asudarsa
Copy link
Contributor

Several user defined/declared functions were being identified as 'possible' OpenCL builtins as they had prefixes (e.g. atomic_) similar to OpenCL builtin function names. However, they were not present in the OCLSPIRVBuiltinMap.
One of the OCLToSPIRV utility functions calls OCLSPIRVBuiltinMap::map function on such user defined functions and this results in a crash.
The correct way to do this will be to check if the OCL function name key is present in the map and exit early if not.

This PR does that.

Thanks

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
@asudarsa asudarsa requested a review from svenvh April 22, 2024 13:25
@asudarsa
Copy link
Contributor Author

This PR should help us to get #2500 back by reverting #2508

Thanks

@bwlodarcz
Copy link
Contributor

The fix of the issue is likely a little bigger than "atomic". The changes covers "atomic" prefix but there are other prefixes in OCLToSPIRVBase::visitCallInst in OCLToSPIRV.cpp:196 like "convert" or "VLoad" which needs to be handled with care as well. I didn't do deep dive but by quickly glimpsing the code of the function handling that cases it's imaginable to lead Translator again into bogus state by carefully crafted function name. What do you think @MrSidims, @asudarsa?

@MrSidims MrSidims added stale Old not addressed issues and removed stale Old not addressed issues labels Apr 23, 2024
@asudarsa
Copy link
Contributor Author

The fix of the issue is likely a little bigger than "atomic". The changes covers "atomic" prefix but there are other prefixes in OCLToSPIRVBase::visitCallInst in OCLToSPIRV.cpp:196 like "convert" or "VLoad" which needs to be handled with care as well. I didn't do deep dive but by quickly glimpsing the code of the function handling that cases it's imaginable to lead Translator again into bogus state by carefully crafted function name. What do you think @MrSidims, @asudarsa?

Hi @bwlodarcz

Thanks much for the feedback.
I am now trying several tests trying to manually create the user defined functions with OCL looking names. I will update the PR with my findings.

Sincerely

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.

6 participants