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

Prevent races between dropping File LockGuard and waking its tasks #1056

Merged
merged 1 commit into from
Apr 7, 2023

Conversation

Enselic
Copy link
Contributor

@Enselic Enselic commented Apr 7, 2023

By changing the inner LockGuard value to an Option and setting it to None in drop() so we can drop the Arc before waking its tasks.

Closes #1001

I have not added a regression test, because the only practical test I can think of is the busy loop, but I don't think we want a test like that.

I can easily reproduce the panic without the fix (the test crashes within 0.1-7 seconds on my machine), but with the fix I get no crash (I waited for 8 minutes).

To be honest I am not 110% sure that the fix is 100% sound, but intuitively this feels like a good fix. Maybe it is obviously correct (or obviously wrong) to people who are more familiar with this code base. I'm confident enough in the fix to consider it ready for CR at least.

By changing the inner `LockGuard` value to an `Option` and setting it to
`None` in `drop()` so we can drop the `Arc` _before_ waking its tasks.
@joshtriplett joshtriplett merged commit 707fd53 into async-rs:main Apr 7, 2023
19 checks passed
@Enselic Enselic deleted the prevent-lock-guard-races branch April 7, 2023 06:09
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.

panic in async_std::fs::File::into_raw_fd
2 participants