Skip to content

[SYCL][Driver] Remove temporary string usage in HandleXarchArgs #13248

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 2 commits into from
Apr 5, 2024

Conversation

jinge90
Copy link
Contributor

@jinge90 jinge90 commented Apr 2, 2024

We should use string which is valid during the whole compilation phase instead of a temporary string.

@jinge90 jinge90 requested a review from a team as a code owner April 2, 2024 08:17
@jinge90 jinge90 requested a review from mdtoguchi April 2, 2024 08:18
@jinge90 jinge90 temporarily deployed to WindowsCILock April 2, 2024 08:18 — with GitHub Actions Inactive
@jinge90 jinge90 temporarily deployed to WindowsCILock April 2, 2024 08:54 — with GitHub Actions Inactive
@@ -99,7 +99,7 @@ static void HandleXarchArgs(DerivedArgList *OffloadArgList, const Driver &D,
OffloadArgList->MakeArgStringRef(XarchVecs[Index]));
}
} else
XarchValueRefs.push_back(StringRef(XarchV));
XarchValueRefs.push_back(OffloadArgList->MakeArgString(XarchV));
Copy link
Contributor

Choose a reason for hiding this comment

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

Any way we can capture the bad behavior in a test other than running through the sanitizer?

Copy link
Contributor Author

@jinge90 jinge90 Apr 2, 2024

Choose a reason for hiding this comment

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

Hi, @mdtoguchi
The sycl-xarch.cpp test has covered this line of code already but it just passed due to good luck. This behavior is a general problem, a temporary value is still used when it is out of scope. Sometimes, the memory of this value is not touched even when it is out of scope, this is why this test happened to pass. In some platform, the memory of this temporary value may be modified, then we will see the lit test fails.
It is very difficult to catch such kind of errors because we can't make the temporary value's memory to be changed when it is out of scope and memory sanitizer is invented to detect such bugs via shadow memory mechanism.
Thanks very much.

@jinge90 jinge90 requested a review from mdtoguchi April 2, 2024 14:12
@jinge90 jinge90 temporarily deployed to WindowsCILock April 3, 2024 02:24 — with GitHub Actions Inactive
@jinge90 jinge90 temporarily deployed to WindowsCILock April 3, 2024 03:00 — with GitHub Actions Inactive
@jinge90 jinge90 requested a review from a team April 3, 2024 05:11
@jinge90
Copy link
Contributor Author

jinge90 commented Apr 3, 2024

Hi, @intel/llvm-gatekeepers
Could you help merge this patch?
Thanks very much.

@sommerlukas
Copy link
Contributor

@srividya-sundaram Can you please approve this PR if you're content with the resolution of your comment?

@jinge90
Copy link
Contributor Author

jinge90 commented Apr 4, 2024

Hi, @intel/llvm-gatekeepers
Kind ping~
Thanks very much.

@sommerlukas sommerlukas merged commit 4f6ccb2 into intel:sycl Apr 5, 2024
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.

4 participants