From 0783797520cd04241901615e586bd0aa806aaad5 Mon Sep 17 00:00:00 2001 From: Motoyuki Kimura Date: Sat, 5 Jul 2025 17:41:37 +0900 Subject: [PATCH] runtime: fix handling of cancelled io_uring Ops (#7436) --- tokio/src/runtime/io/driver/uring.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/io/driver/uring.rs b/tokio/src/runtime/io/driver/uring.rs index f828df314..3370164d1 100644 --- a/tokio/src/runtime/io/driver/uring.rs +++ b/tokio/src/runtime/io/driver/uring.rs @@ -289,7 +289,10 @@ impl Handle { match mem::replace(lifecycle, Lifecycle::Cancelled(cancel_data)) { Lifecycle::Submitted | Lifecycle::Waiting(_) => (), // The driver saw the completion, but it was never polled. - Lifecycle::Completed(_) => (), + Lifecycle::Completed(_) => { + // We can safely remove the entry from the slab, as it has already been completed. + ops.remove(index); + } prev => panic!("Unexpected state: {:?}", prev), }; }