Skip to content

[SYCL] Fix crash on array of pointers #2413

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 4 commits into from
Sep 4, 2020

Conversation

elizabethandrews
Copy link
Contributor

@elizabethandrews elizabethandrews commented Sep 2, 2020

The crash happens when address space of pointer element is
checked using array type. The type of 'array element' should
be checked, not the 'array type' itself. Also added a missing
LValueToRValue cast for pointers.

Signed-off-by: Elizabeth Andrews [email protected]

The crash happens when address space of pointer element is
checked using array type. The type of 'array element' should
be checked, not the 'array type' itself.

Signed-off-by: Elizabeth Andrews <[email protected]>
Copy link
Contributor

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

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

Cool, easier than I thought :)

Does this work for arrays-of-pointers in the 'root' lambda? So something like:

void foo() {
  int *array[2];
  kernel<class whatever>([=](){ return array[0];});
}

@elizabethandrews
Copy link
Contributor Author

Cool, easier than I thought :)

Does this work for arrays-of-pointers in the 'root' lambda? So something like:

void foo() {
  int *array[2];
  kernel<class whatever>([=](){ return array[0];});
}

I think so. I will add a test for that as well. Unfortunately though, I was just running some tests locally and it crashed for the 2D array of pointers in CodeGen :/ I'm not sure why check-all didn't show this when I tested it earlier. The runtime test should have crashed.

@elizabethandrews elizabethandrews changed the title [SYCL] Fix crash on array of pointers [Do not merge][SYCL] Fix crash on array of pointers Sep 2, 2020
@elizabethandrews elizabethandrews marked this pull request as draft September 2, 2020 16:14
@erichkeane
Copy link
Contributor

Cool, easier than I thought :)
Does this work for arrays-of-pointers in the 'root' lambda? So something like:

void foo() {
  int *array[2];
  kernel<class whatever>([=](){ return array[0];});
}

I think so. I will add a test for that as well. Unfortunately though, I was just running some tests locally and it crashed for the 2D array of pointers in CodeGen :/ I'm not sure why check-all didn't show this when I tested it earlier. The runtime test should have crashed.

Well, the question is more, "Are they wrapped" (I don't think so), and should they be?

@elizabethandrews
Copy link
Contributor Author

elizabethandrews commented Sep 2, 2020

Well, the question is more, "Are they wrapped" (I don't think so), and should they be?

No they aren't. And they shouldn't be because that affects current USM functionality. We're maintaining struct depth to avoid this. The wrapping was added in a prior commit to get rid of runtime errors which came as a result of decomposition for unused pointers in structs. These should just be ignored by compiler (since they're not used). If they ever are incorrectly used it'll crash/error in backend.

@vladimirlaz
Copy link
Contributor

Cool, easier than I thought :)
Does this work for arrays-of-pointers in the 'root' lambda? So something like:

void foo() {
  int *array[2];
  kernel<class whatever>([=](){ return array[0];});
}

I think so. I will add a test for that as well. Unfortunately though, I was just running some tests locally and it crashed for the 2D array of pointers in CodeGen :/ I'm not sure why check-all didn't show this when I tested it earlier. The runtime test should have crashed.

@elizabethandrews, check-sycl is not a not part of check-all.

@elizabethandrews
Copy link
Contributor Author

Cool, easier than I thought :)
Does this work for arrays-of-pointers in the 'root' lambda? So something like:

void foo() {
  int *array[2];
  kernel<class whatever>([=](){ return array[0];});
}

I think so. I will add a test for that as well. Unfortunately though, I was just running some tests locally and it crashed for the 2D array of pointers in CodeGen :/ I'm not sure why check-all didn't show this when I tested it earlier. The runtime test should have crashed.

@elizabethandrews, check-sycl is not a not part of check-all.

Oh really? That explains it then. I've always run check-all to make sure tests are passing but I guess I need to run check-all and check-sycl. Thanks for letting me know!

for array of pointers not inside a struct.

Signed-off-by: Elizabeth Andrews <[email protected]>
@elizabethandrews elizabethandrews changed the title [Do not merge][SYCL] Fix crash on array of pointers [SYCL] Fix crash on array of pointers Sep 3, 2020
@elizabethandrews elizabethandrews marked this pull request as ready for review September 3, 2020 18:47
Use comment syntax when passing nullptr

Signed-off-by: Elizabeth Andrews <[email protected]>
Fznamznon
Fznamznon previously approved these changes Sep 4, 2020
Signed-off-by: Elizabeth Andrews <[email protected]>
@elizabethandrews
Copy link
Contributor Author

@intel/llvm-reviewers-runtime there is a runtime test change. It only adds unused array of pointers to a struct to confirm the code does not crash in this case.

Copy link
Contributor

@alexbatashev alexbatashev left a comment

Choose a reason for hiding this comment

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

Runtime changes LGTM

@elizabethandrews
Copy link
Contributor Author

Thanks for the reviews everyone! @bader this is ready for your review/merge.

@pvchupin pvchupin merged commit 1fc0e4f into intel:sycl Sep 4, 2020
martygrant added a commit to martygrant/llvm that referenced this pull request Dec 4, 2024
Chenyang-L pushed a commit that referenced this pull request Feb 18, 2025
[L0] Shorten the dir name for the fecthed repo to avoid hitting Windows max limit
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