diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9db06161134..6503c0e64ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -991,10 +991,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Rust 1.81 + - name: Install Rust 1.88.0 uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.81 + toolchain: 1.88.0 - name: Install wasm-pack uses: taiki-e/install-action@wasm-pack @@ -1014,10 +1014,10 @@ jobs: - wasm32-wasip1-threads steps: - uses: actions/checkout@v4 - - name: Install Rust ${{ env.rust_stable }} + - name: Install Rust 1.88.0 uses: dtolnay/rust-toolchain@stable with: - toolchain: ${{ env.rust_stable }} + toolchain: 1.88.0 targets: ${{ matrix.target }} # Install dependencies diff --git a/Cargo.lock b/Cargo.lock index 05ed852f49c..35c19381945 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -666,11 +666,11 @@ dependencies = [ [[package]] name = "matchers" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -790,12 +790,11 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "nu-ansi-term" -version = "0.46.0" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "overload", - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -838,12 +837,6 @@ version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "parking_lot" version = "0.12.4" @@ -989,7 +982,7 @@ dependencies = [ "rand 0.9.2", "rand_chacha 0.9.0", "rand_xorshift", - "regex-syntax 0.8.5", + "regex-syntax", "rusty-fork", "tempfile", "unarray", @@ -1121,17 +1114,8 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.9", - "regex-syntax 0.8.5", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", + "regex-automata", + "regex-syntax", ] [[package]] @@ -1142,15 +1126,9 @@ checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.5", + "regex-syntax", ] -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - [[package]] name = "regex-syntax" version = "0.8.5" @@ -1288,9 +1266,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" @@ -1412,7 +1390,7 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.2" +version = "1.43.3" dependencies = [ "async-stream", "backtrace", @@ -1593,14 +1571,14 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" dependencies = [ "matchers", "nu-ansi-term", "once_cell", - "regex", + "regex-automata", "sharded-slab", "smallvec", "thread_local", @@ -1781,22 +1759,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.9" @@ -1806,12 +1768,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows" version = "0.61.3" diff --git a/README.md b/README.md index b29336988d9..f26c1d9e4ba 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.43.2", features = ["full"] } +tokio = { version = "1.43.3", features = ["full"] } ``` Then, on your main.rs: diff --git a/tests-build/tests/fail/macros_type_mismatch.stderr b/tests-build/tests/fail/macros_type_mismatch.stderr index 579c241559b..dacc5bef9ca 100644 --- a/tests-build/tests/fail/macros_type_mismatch.stderr +++ b/tests-build/tests/fail/macros_type_mismatch.stderr @@ -25,7 +25,7 @@ error[E0308]: mismatched types found enum `Result<(), _>` help: a return type might be missing here | -9 | async fn missing_return_type() -> _ { + 9 | async fn missing_return_type() -> _ { | ++++ help: consider using `Result::expect` to unwrap the `Result<(), _>` value, panicking if the value is a `Result::Err` | diff --git a/tokio/CHANGELOG.md b/tokio/CHANGELOG.md index f790e989bfa..3ea19d2bccd 100644 --- a/tokio/CHANGELOG.md +++ b/tokio/CHANGELOG.md @@ -1,3 +1,15 @@ +# 1.43.3 (October 14th, 2025) + +### Fixed + +- runtime: use release ordering in `wake_by_ref()` even if already woken ([#7622]) +- sync: close the `broadcast::Sender` in `broadcast::Sender::new()` ([#7629]) +- process: fix error when runtime is shut down on nightly-2025-10-12 ([#7672]) + +[#7622]: https://github.com/tokio-rs/tokio/pull/7622 +[#7629]: https://github.com/tokio-rs/tokio/pull/7629 +[#7672]: https://github.com/tokio-rs/tokio/pull/7672 + # 1.43.2 (August 1st, 2025) ### Fixed diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 9730f0d42bf..a87b9d77d8f 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -6,7 +6,7 @@ name = "tokio" # - README.md # - Update CHANGELOG.md. # - Create "v1.x.y" git tag. -version = "1.43.2" +version = "1.43.3" edition = "2021" rust-version = "1.70" authors = ["Tokio Contributors "] diff --git a/tokio/README.md b/tokio/README.md index b29336988d9..f26c1d9e4ba 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.43.2", features = ["full"] } +tokio = { version = "1.43.3", features = ["full"] } ``` Then, on your main.rs: diff --git a/tokio/src/process/unix/pidfd_reaper.rs b/tokio/src/process/unix/pidfd_reaper.rs index 2574f360fbd..f29e99b1d1a 100644 --- a/tokio/src/process/unix/pidfd_reaper.rs +++ b/tokio/src/process/unix/pidfd_reaper.rs @@ -95,14 +95,41 @@ where pidfd: PollEvented, } +fn display_eq(d: impl std::fmt::Display, s: &str) -> bool { + use std::fmt::Write; + + struct FormatEq<'r> { + remainder: &'r str, + unequal: bool, + } + + impl<'r> Write for FormatEq<'r> { + fn write_str(&mut self, s: &str) -> std::fmt::Result { + if !self.unequal { + if let Some(new_remainder) = self.remainder.strip_prefix(s) { + self.remainder = new_remainder; + } else { + self.unequal = true; + } + } + Ok(()) + } + } + + let mut fmt_eq = FormatEq { + remainder: s, + unequal: false, + }; + let _ = write!(fmt_eq, "{d}"); + fmt_eq.remainder.is_empty() && !fmt_eq.unequal +} + #[allow(deprecated)] fn is_rt_shutdown_err(err: &io::Error) -> bool { if let Some(inner) = err.get_ref() { - // Using `Error::description()` is more efficient than `format!("{inner}")`, - // so we use it here even if it is deprecated. err.kind() == io::ErrorKind::Other && inner.source().is_none() - && inner.description() == RUNTIME_SHUTTING_DOWN_ERROR + && display_eq(inner, RUNTIME_SHUTTING_DOWN_ERROR) } else { false } diff --git a/tokio/src/runtime/task/state.rs b/tokio/src/runtime/task/state.rs index da3e8d38d91..2d3a1b5c4b5 100644 --- a/tokio/src/runtime/task/state.rs +++ b/tokio/src/runtime/task/state.rs @@ -252,9 +252,15 @@ impl State { /// Transitions the state to `NOTIFIED`. pub(super) fn transition_to_notified_by_ref(&self) -> TransitionToNotifiedByRef { self.fetch_update_action(|mut snapshot| { - if snapshot.is_complete() || snapshot.is_notified() { - // There is nothing to do in this case. + if snapshot.is_complete() { + // The complete state is final (TransitionToNotifiedByRef::DoNothing, None) + } else if snapshot.is_notified() { + // Even hough we have nothing to do in this branch, + // wake_by_ref() should synchronize-with the task starting execution, + // therefore we must use an Release store (with the same value), + // to pair with the Acquire in transition_to_running. + (TransitionToNotifiedByRef::DoNothing, Some(snapshot)) } else if snapshot.is_running() { // If the task is running, we mark it as notified, but we should // not submit as the thread currently running the future is diff --git a/tokio/src/sync/broadcast.rs b/tokio/src/sync/broadcast.rs index b48493be26c..a69eca661ea 100644 --- a/tokio/src/sync/broadcast.rs +++ b/tokio/src/sync/broadcast.rs @@ -522,7 +522,7 @@ impl Sender { tail: Mutex::new(Tail { pos: 0, rx_cnt: receiver_count, - closed: false, + closed: receiver_count == 0, waiters: LinkedList::new(), }), num_tx: AtomicUsize::new(1), diff --git a/tokio/tests/sync_broadcast.rs b/tokio/tests/sync_broadcast.rs index 3af96bdb5d5..d485c63076f 100644 --- a/tokio/tests/sync_broadcast.rs +++ b/tokio/tests/sync_broadcast.rs @@ -656,3 +656,15 @@ async fn receiver_recv_is_cooperative() { _ = tokio::task::yield_now() => {}, } } + +#[tokio::test] +async fn broadcast_sender_new_must_be_closed() { + let capacity = 1; + let tx: broadcast::Sender<()> = broadcast::Sender::new(capacity); + + tx.send(()).unwrap_err(); + + let _rx = tx.subscribe(); + + tx.send(()).unwrap(); +}