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

Use CancelIoEx instead of CancelIo on windows_native #152

Merged
merged 1 commit into from
Mar 2, 2024

Conversation

YgorSouza
Copy link
Contributor

Fixes a use-after-free bug when dropping the HidDevice from a thread other than the one that was last used to read it, because of a pending async operation that did not get canceled.

If the cancellation does not return an error, we get the overlapped result to block until it actually goes through. This is recommended by Microsoft in this example:
https://learn.microsoft.com/en-us/windows/win32/fileio/canceling-pending-i-o-operations#canceling-asynchronous-io.

Closes #151

Fixes a use-after-free bug when dropping the HidDevice from a thread
other than the one that was last used to read it, because of a pending
async operation that did not get canceled.

If the cancellation does not return an error, we get the overlapped
result to block until it actually goes through. This is recommended by
Microsoft in this example:
<https://learn.microsoft.com/en-us/windows/win32/fileio/canceling-pending-i-o-operations#canceling-asynchronous-io>.

Closes ruabmbua#151
@ruabmbua ruabmbua merged commit f37a860 into ruabmbua:main Mar 2, 2024
9 checks passed
@ruabmbua
Copy link
Owner

ruabmbua commented Mar 2, 2024

Thanks for fixing this, will release a new version to crates.io.

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.

HidDevice::drop is not thread safe on Windows
2 participants