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

[DeviceASAN] Fix urKernelCreateWithNativeHandle segfault #2506

Merged
merged 3 commits into from
Jan 6, 2025

Conversation

AllanZyne
Copy link
Contributor

@AllanZyne AllanZyne commented Dec 24, 2024

LLVM: intel/llvm#16473

Since we can't get nullptr when calling getKernelInfo, I changed the return type of this function to reference.

To make it support "urKernelCreateXXX" APIs automatically, I changed getKernelInfo to getOrCreateKernelInfo, so that we needn't intercept "urKernelCreateXXX" anymore.

Sync those changes to msan.

@AllanZyne AllanZyne requested a review from a team as a code owner December 24, 2024 07:29
@github-actions github-actions bot added the loader Loader related feature/bug label Dec 24, 2024
m_KernelMap.emplace(Kernel,
std::make_shared<KernelInfo>(Kernel, IsInstrumented));
return UR_RESULT_SUCCESS;
std::make_unique<KernelInfo>(Kernel, IsInstrumented));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why bother using a unique_ptr if there is no ownership change? We can just use raw pointer here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to manually delete them if it's raw pointer. unique_ptr is more convenient here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then we can just use the object created by the map. It should be deleted when being erased from then map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we can just use the object created by the map. It should be deleted when being erased from then map.

I've tried this but encountered a difficult-to-solve compilation error.
Using unqiue_ptr is a simple solution here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I am fine with this as a temporary solution. We plan to refactor related code in near future anyway. We can discuss for any better solution in that time.

@AllanZyne
Copy link
Contributor Author

@oneapi-src/unified-runtime-maintain, please add to 2025.1

@aarongreig aarongreig added the v0.11.x Include in the v0.11.x release label Dec 26, 2024
@yingcong-wu
Copy link
Contributor

Hi @zhaomaosu , please help review this PR.

Copy link
Contributor

@zhaomaosu zhaomaosu left a comment

Choose a reason for hiding this comment

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

lgtm

@kbenzie kbenzie merged commit 0eb08b6 into oneapi-src:main Jan 6, 2025
73 checks passed
@kbenzie
Copy link
Contributor

kbenzie commented Jan 6, 2025

Changes pulled in by intel/llvm#16478.

kbenzie added a commit that referenced this pull request Jan 7, 2025
[DeviceASAN] Fix urKernelCreateWithNativeHandle segfault
kbenzie added a commit that referenced this pull request Jan 7, 2025
[DeviceASAN] Fix urKernelCreateWithNativeHandle segfault
kbenzie added a commit that referenced this pull request Jan 8, 2025
[DeviceASAN] Fix urKernelCreateWithNativeHandle segfault
kbenzie added a commit that referenced this pull request Jan 8, 2025
[DeviceASAN] Fix urKernelCreateWithNativeHandle segfault
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
loader Loader related feature/bug v0.11.x Include in the v0.11.x release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants