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

Possible use-after-free when handler is destroyed before operation completes? #26

Open
igchor opened this issue May 5, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@igchor
Copy link
Member

igchor commented May 5, 2023

Consider the following code:

{
    auto h = dml::submit<path>(...);
}

The handler returned from submit may be destroyed before the operation completes. I don't see any mention in the documentation that the handler should be kept alive until the operation completes, so I would assume this code is valid.

However, I believe this can cause use-after-free in the hardware path since DML will try to write the completion status to the descriptor (which, if I understand correctly, is owned by the handler). Possibly the same is true for C API and dml_finalize_job().

Is my understanding correct or this is already handled by the DML somehow? If not, I think the best way to avoid this would be to wait for the operation to complete inside the handler destructor.

@mzhukova mzhukova self-assigned this May 23, 2023
@mzhukova
Copy link
Contributor

Hi @igchor, it is a valid concern and you understanding is correct, thanks for bringing this issue!
I believe short-term we will update the documentation/code to mention that user should keep handler alive and long-term we will explore how to address it better.

@mzhukova mzhukova added the bug Something isn't working label May 23, 2023
@mzhukova
Copy link
Contributor

Just FYI, the documentation was updated to reflect this limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants