From 4152918a39214d22e4b9e8d2148641b38b4f1c6e Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 24 Aug 2021 11:58:30 +0000 Subject: [PATCH 1/2] runtime: fix leak in UnownedTask --- tokio/src/runtime/task/mod.rs | 10 ++++++++-- tokio/src/runtime/tests/task.rs | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tokio/src/runtime/task/mod.rs b/tokio/src/runtime/task/mod.rs index cc3910d4b..5f0d5aba1 100644 --- a/tokio/src/runtime/task/mod.rs +++ b/tokio/src/runtime/task/mod.rs @@ -369,10 +369,16 @@ impl UnownedTask { let raw = self.raw; mem::forget(self); - // Poll the task + // Transfer one ref-count to a Task object. + let task = Task:: { + raw, + _p: PhantomData, + }; + + // Use the other ref-count to poll the task. raw.poll(); // Decrement our extra ref-count - raw.header().state.ref_dec(); + drop(task); } pub(crate) fn shutdown(self) { diff --git a/tokio/src/runtime/tests/task.rs b/tokio/src/runtime/tests/task.rs index e93a1efe6..04e1b56e7 100644 --- a/tokio/src/runtime/tests/task.rs +++ b/tokio/src/runtime/tests/task.rs @@ -111,6 +111,12 @@ fn create_shutdown2() { drop(join); } +#[test] +fn unowned_poll() { + let (task, _) = unowned(async {}, NoopSchedule); + task.run(); +} + #[test] fn schedule() { with(|rt| { From dd060b16f54ce196b3891042030dedd3abc017c4 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 24 Aug 2021 12:28:19 +0000 Subject: [PATCH 2/2] chore: prepare Tokio v1.10.1 --- README.md | 2 +- tokio/CHANGELOG.md | 8 ++++++++ tokio/Cargo.toml | 2 +- tokio/README.md | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a06d873ed..80f75be74 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml: ```toml [dependencies] -tokio = { version = "1.10.0", features = ["full"] } +tokio = { version = "1.10.1", features = ["full"] } ``` Then, on your main.rs: diff --git a/tokio/CHANGELOG.md b/tokio/CHANGELOG.md index 55b120fdd..3b419570b 100644 --- a/tokio/CHANGELOG.md +++ b/tokio/CHANGELOG.md @@ -1,3 +1,11 @@ +# 1.10.1 (August 24, 2021) + +### Fixed + + - runtime: fix leak in UnownedTask ([#4063]) + +[#4063]: https://github.com/tokio-rs/tokio/pull/4063 + # 1.10.0 (August 12, 2021) ### Added diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index da8e4b694..90455fb9e 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -7,7 +7,7 @@ name = "tokio" # - README.md # - Update CHANGELOG.md. # - Create "v1.0.x" git tag. -version = "1.10.0" +version = "1.10.1" edition = "2018" authors = ["Tokio Contributors "] license = "MIT" diff --git a/tokio/README.md b/tokio/README.md index a06d873ed..80f75be74 100644 --- a/tokio/README.md +++ b/tokio/README.md @@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml: ```toml [dependencies] -tokio = { version = "1.10.0", features = ["full"] } +tokio = { version = "1.10.1", features = ["full"] } ``` Then, on your main.rs: