Skip to content

io_uring fs operations can panic when runtime IO is disabled #8164

@fallintoplace

Description

@fallintoplace

Description

With tokio_unstable, the io-uring feature, and Linux fs support enabled, several tokio::fs APIs probe the runtime io_uring driver before falling back to the blocking filesystem path. Those probes call the panicking driver().io() accessor.

If a Tokio runtime exists but was built without IO enabled, these filesystem operations can panic before reaching the existing spawn_blocking fallback.

Affected paths

Examples include:

  • tokio::fs::read
  • tokio::fs::write
  • tokio::fs::OpenOptions::open
  • tokio::fs::File reads from File::from_std

Example

let rt = tokio::runtime::Builder::new_current_thread()
    .build()
    .unwrap();

rt.block_on(async {
    let _ = tokio::fs::read("foo.txt").await;
});

In an io_uring-enabled build, this can panic with the IO-disabled runtime message before falling back to the blocking filesystem implementation.

Expected behavior

If the runtime has no IO driver, the optional io_uring path should be skipped and filesystem operations should use the existing blocking fallback. This matches the existing fallback behavior when io_uring is unavailable or unsupported.

Notes

This is limited to Linux tokio_unstable + io-uring builds, so it does not affect normal stable Tokio builds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateM-fsModule: tokio/fs

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions