fs: don't poison File when blocking op is cancelled - #8291
Merged
Conversation
kilyanni
force-pushed
the
fix/cancelled-fs-poisoning
branch
from
July 16, 2026 17:36
fbb0ed6 to
74ed2b6
Compare
kilyanni
marked this pull request as draft
July 16, 2026 17:41
kilyanni
force-pushed
the
fix/cancelled-fs-poisoning
branch
2 times, most recently
from
July 16, 2026 17:54
ba918b9 to
9b52514
Compare
Previously, running certain tokio::fs::File ops (read, seek, etc) after the backing blocking task was cancelled (e.g. due to a runtime shutdown) would lead to the second operation panicking, instead of erroring out gracefully. This is due to the ops returing via `?` without resetting their internal state into a valid one.
kilyanni
force-pushed
the
fix/cancelled-fs-poisoning
branch
from
July 16, 2026 17:54
9b52514 to
29add6c
Compare
kilyanni
marked this pull request as ready for review
July 16, 2026 17:56
ADD-SP
self-requested a review
August 8, 2026 17:00
Darksonn
approved these changes
Aug 9, 2026
Member
|
It looks ok to me, but it looks like @ADD-SP also wants to review. |
Contributor
Author
|
Thanks for the merge! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
tokio::fs::Filetracks its blocking ops with anIdle -> Busy -> Idlestate machine. When a blocking task is cancelled (e.g. on runtime shutdown) or fails to spawn, the error path returns mid-transition and leaves an invalid state, so the next op panics.Affects
read/write/seek/flush/set_len.Found in the wild as a flaky
JoinHandle polled after completioncrash in Wasmer, which was tearing down a tokio runtime while host-file I/O was still in flight.Solution
Reset to a valid
Idlestate before returning the error. Only error branches are touched, success/Pendingpaths are unchanged.Adds a regression test.