-
Notifications
You must be signed in to change notification settings - Fork 794
[Clang][SYCL] Fix dangling pointers and ODR violation in free functions #20422
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
Conversation
Recently, there were several occurrences where developers manually updated the ABI symbol dump file to add a new symbol. This results into unrelated changes on PRs when someone correctly uses `abi_check.py` file to regenerate the ABI symbols, (for example: #20422) This PR makes `abi_check.py` to fail if the order of ABI symbols is incorrect, thus discouraging developers from manually editing the symbol dump file.
fdaeb84 to
eab57bd
Compare
|
Should this have an E2E test? Though it's possible that this is already exercised by some of the IntermediateLib tests ( https://github.com/intel/llvm/blob/sycl/sycl/test-e2e/IntermediateLib/multi_lib_app.cpp ) |
72823b4 to
2079eb2
Compare
@cperkinsintel I'm finding it hard to reproduce the dangling pointer bug using an E2E/LIT test, although it's easily reproducible using valgrind. The rest of the code changes in this PR can be tested by existing FreeFunction tests. |
|
Along with dangling pointers, there's another bug in current FreeFunction implementation. |
|
@elizabethandrews (@intel/dpcpp-cfe-reviewers) Can you please re-review the FE changes? I made a minor change (2079eb2) since the last review. Thanks! |
|
@intel/llvm-gatekeepers please consider merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, minor nits.
| namespace free_function_info_map { | ||
|
|
||
| __SYCL_EXPORT void add(const void *DeviceGlobalPtr, const char *UniqueId); | ||
| __SYCL_EXPORT void remove(const void *DeviceGlobalPtr, const char *UniqueId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were the changes in this file needed? (I understand it is the mock header, but I don't see this tested in SemaSYCL anywhere.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dklochkov-emb since this file was added in https://github.com/intel/llvm/pull/19517/files#diff-dfac134a49adec0ea0525b0941ce5b5e8b51c64e0692aae6c8f0105b9936106e, do you know how is it being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as I know it is needed for SemaSYCL tests, i.e. it mocks real header. For example, test file
https://github.com/intel/llvm/blob/sycl/clang/test/SemaSYCL/free_function_kernel_params.cpp
contains -internal-isystem %S/Inputs. In my understanding, this file will be visible to include as the system file after that
Co-authored-by: premanandrao <[email protected]>
Problems
Problem 1: When a library consisting of free function kernels is registered with SYCL RT, we store pointers (as
string_view) to free function names inm_FreeFunctionKernelGlobalInfobut we do not remove them fromm_FreeFunctionKernelGlobalInfowhen the library is unloaded. Thus, we end up holding dangling pointers and any further operation onm_FreeFunctionKernelGlobalInfomight segfault.Problem 2: Consider the case when you have multiple TUs with free functions and they are compiled separately but linked together into a single shared lib. In that case, we will have multiple definition of
static GlobalMapUpdater updaterin the shared lib => violating ODRSolution
Discard pointers to free function names when library is unloaded and have
GlobalMapUpdaterdefined in anonymous namespace, instead ofsycl::v1::detail