Skip to content

Conversation

@schittir
Copy link
Contributor

@schittir schittir commented Aug 18, 2021

Add assert that arguments of work_group_size attributes cannot be nullptr

Klocwork exposed a (false positive) bug that nullptr derferencing of
YDimExpr and ZDimExpr is possible for non sycl:: usage.
This is not practically possible because such (OpenCL and cl::) spellings
of the attribute require three arguments.

This patch

  1. Removes the ability of SetDefaultValue lambda to return nullptr
  2. Asserts in SetDefaultValue that it is not possible for sycl:: case
    to have NULL arguments
  3. Moves error checking for three arguments for OpenCL and cl:: cases
    ahead of the assert
  4. Removes check for intel::reqd_work_group_size spelling

Fix the Klocworks exposed bug for non sycl:: or intel:: usage by
refactoring and adding checks to avoid nullptr dereferencing
erichkeane
erichkeane previously approved these changes Aug 24, 2021
premanandrao
premanandrao previously approved these changes Aug 24, 2021
Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

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

LGTM

@schittir
Copy link
Contributor Author

Fixing commit message now.

AaronBallman
AaronBallman previously approved these changes Aug 24, 2021
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM! Can you also add "NFC" to the review title as this has no functional change?

@schittir schittir changed the title [SYCL] Avoid nullptr dereferencing of YDimExpr and ZDimExpr [SYCL][NFC] Avoid nullptr dereferencing of YDimExpr and ZDimExpr Aug 24, 2021
@schittir
Copy link
Contributor Author

Thank you for the review, @erichkeane @AaronBallman - I updated the description and title.

Thanks @premanandrao

@schittir
Copy link
Contributor Author

Working on reproducing the test failures locally.

@schittir
Copy link
Contributor Author

Working on reproducing the test failures locally.

Still unable to reproduce the failure locally. Machine ran out of space meanwhile. Will try a diferent macine.

Do it after checking for 3 argument requirement for OpenCL and cl::
spellings
@schittir schittir dismissed stale reviews from AaronBallman and premanandrao via 11f0a79 September 2, 2021 22:14
Assert in SetDefaultValue that it is not possible for sycl:: or intel::
cases to have NULL arguments

Move error checking of three arguments for OpenCL and cl:: cases ahead
of the assert in SetDefaultValue
AaronBallman
AaronBallman previously approved these changes Sep 8, 2021
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM aside from a microscopic commenting nit, thanks!

@schittir
Copy link
Contributor Author

schittir commented Sep 8, 2021

Removed extra // and updated description. @AaronBallman Could you please take a look and approve again? Thank you.

Copy link
Contributor

@smanna12 smanna12 left a comment

Choose a reason for hiding this comment

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

Thanks for the patch.

Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM!

@schittir
Copy link
Contributor Author

schittir commented Sep 8, 2021

LGTM!

Thank you for all the reviews!

@dm-vodopyanov
Copy link
Contributor

@schittir, can you add a test for these changes?

@schittir
Copy link
Contributor Author

schittir commented Sep 8, 2021

@schittir, can you add a test for these changes?

I don't think there is a real case where the assert is false. This is a non-functional change made to appease Klocwork.

@dm-vodopyanov dm-vodopyanov merged commit 6e9fa89 into intel:sycl Sep 8, 2021
Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

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

Post-factum LGTM

DoyleLi pushed a commit to DoyleLi/intel_llvm that referenced this pull request Sep 13, 2021
…el#4367)

Add assert that arguments of work_group_size attributes cannot be nullptr

Klocwork exposed a (false positive) bug that nullptr derferencing of 
YDimExpr and ZDimExpr is possible for non sycl:: usage.
This is not practically possible because such (OpenCL and cl::) spellings
of the attribute require three arguments.

This patch
1.  Removes the ability of SetDefaultValue lambda to return nullptr
2. Asserts in SetDefaultValue that it is not possible for sycl:: case 
to have NULL arguments
3.  Moves error checking for three arguments for OpenCL and cl:: cases 
ahead of the assert 
4. Removes check for intel::reqd_work_group_size spelling
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.

7 participants