Skip to content

Commit 5d5cd8b

Browse files
committed
Merge 'tokio-1.53.2' into 'master' (#8578)
2 parents 11d1ca0 + ff0c406 commit 5d5cd8b

63 files changed

Lines changed: 1465 additions & 400 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Make sure you enable the full features of the tokio crate on Cargo.toml:
5656

5757
```toml
5858
[dependencies]
59-
tokio = { version = "1.53.1", features = ["full"] }
59+
tokio = { version = "1.53.2", features = ["full"] }
6060
```
6161
Then, on your main.rs:
6262

‎tests-integration/tests/process_stdio.rs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ async fn try_wait() {
142142
assert_eq!(child.id(), None);
143143
}
144144

145+
#[tokio::test]
146+
async fn drop_pending_child_after_poll() {
147+
let mut child = cat().spawn().unwrap();
148+
let stdin = child.stdin.take().unwrap();
149+
150+
{
151+
let mut wait = std::pin::pin!(child.wait());
152+
let waker = futures::task::noop_waker();
153+
let mut cx = std::task::Context::from_waker(&waker);
154+
assert!(std::future::Future::poll(wait.as_mut(), &mut cx).is_pending());
155+
}
156+
157+
drop(child);
158+
drop(stdin);
159+
}
160+
145161
#[tokio::test]
146162
async fn pipe_from_one_command_to_another() {
147163
let mut first = cat().spawn().expect("first cmd");

‎tokio/CHANGELOG.md‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
# 1.53.2 (October 3rd, 2026)
2+
3+
### Fixed
4+
5+
- fs: handle integer overflow in buffered relative seek ([#8574])
6+
- io: revert "always cleanup `AsyncFd` registration list on deregister" ([#8540])
7+
- process: unregister Windows wait before closing child handle ([#8564])
8+
- rt: drop blocking pool mutex before shutting down rejected task ([#8562])
9+
- sync: fix mpsc index wraparound in block reclamation ([#8546])
10+
- sync: forget mpsc `Permit` before sending value ([#8560])
11+
- sync: validate `MAX_PERMITS` in `Semaphore::acquire` ([#8548])
12+
- sync: wake broadcast `Sender::closed` outside mutex ([#8558])
13+
- task: drop replaced waker outside lock in `JoinSet` ([#8554])
14+
- time: drop timer lock before dropping waker in `clear_entry` ([#8552])
15+
- time: expire timers directly on shutdown without rotating wheel ([#8570])
16+
17+
### Fixed (unstable)
18+
19+
- fs: clamp `io_uring` read length to `u32::MAX` ([#8572])
20+
- rt: ignore `current_thread` task dumps from other runtimes ([#8544])
21+
- rt: preserve `io_uring` context if a completion waker panics ([#8566])
22+
- sync: fix semaphore use-after-free and permit leak on tracing panic ([#8542])
23+
- taskdump: restore deferred leaf wakes during capture ([#8445])
24+
- time: drop stored waker when cancelling alt timer entry ([#8550])
25+
26+
[#8445]: https://github.com/tokio-rs/tokio/pull/8445
27+
[#8572]: https://github.com/tokio-rs/tokio/pull/8572
28+
129
# 1.53.1 (July 20th, 2026)
230

331
### Fixed
@@ -180,6 +208,45 @@ This release reverts the LIFO slot stealing change introduced in 1.51.0
180208
[#8035]: https://github.com/tokio-rs/tokio/pull/8035
181209
[#8040]: https://github.com/tokio-rs/tokio/pull/8040
182210

211+
# 1.51.5 (October 3rd, 2026)
212+
213+
### Fixed
214+
215+
- fs: handle integer overflow in buffered relative seek ([#8574])
216+
- io: revert "always cleanup `AsyncFd` registration list on deregister" ([#8540])
217+
- process: unregister Windows wait before closing child handle ([#8564])
218+
- rt: drop blocking pool mutex before shutting down rejected task ([#8562])
219+
- sync: fix mpsc index wraparound in block reclamation ([#8546])
220+
- sync: forget mpsc `Permit` before sending value ([#8560])
221+
- sync: validate `MAX_PERMITS` in `Semaphore::acquire` ([#8548])
222+
- sync: wake broadcast `Sender::closed` outside mutex ([#8558])
223+
- task: drop replaced waker outside lock in `JoinSet` ([#8554])
224+
- time: drop timer lock before dropping waker in `clear_entry` ([#8552])
225+
- time: expire timers directly on shutdown without rotating wheel ([#8570])
226+
227+
### Fixed (unstable)
228+
229+
- rt: ignore `current_thread` task dumps from other runtimes ([#8544])
230+
- rt: preserve `io_uring` context if a completion waker panics ([#8566])
231+
- sync: fix semaphore use-after-free and permit leak on tracing panic ([#8542])
232+
- time: drop stored waker when cancelling alt timer entry ([#8550])
233+
234+
[#8540]: https://github.com/tokio-rs/tokio/pull/8540
235+
[#8542]: https://github.com/tokio-rs/tokio/pull/8542
236+
[#8544]: https://github.com/tokio-rs/tokio/pull/8544
237+
[#8546]: https://github.com/tokio-rs/tokio/pull/8546
238+
[#8548]: https://github.com/tokio-rs/tokio/pull/8548
239+
[#8550]: https://github.com/tokio-rs/tokio/pull/8550
240+
[#8552]: https://github.com/tokio-rs/tokio/pull/8552
241+
[#8554]: https://github.com/tokio-rs/tokio/pull/8554
242+
[#8558]: https://github.com/tokio-rs/tokio/pull/8558
243+
[#8560]: https://github.com/tokio-rs/tokio/pull/8560
244+
[#8562]: https://github.com/tokio-rs/tokio/pull/8562
245+
[#8564]: https://github.com/tokio-rs/tokio/pull/8564
246+
[#8566]: https://github.com/tokio-rs/tokio/pull/8566
247+
[#8570]: https://github.com/tokio-rs/tokio/pull/8570
248+
[#8574]: https://github.com/tokio-rs/tokio/pull/8574
249+
183250
# 1.51.4 (July 16th, 2026)
184251

185252
### Fixed

‎tokio/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name = "tokio"
66
# - README.md
77
# - Update CHANGELOG.md.
88
# - Create "v1.x.y" git tag.
9-
version = "1.53.1"
9+
version = "1.53.2"
1010
edition = "2021"
1111
rust-version = "1.85"
1212
authors = ["Tokio Contributors <[email protected]>"]

‎tokio/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Make sure you enable the full features of the tokio crate on Cargo.toml:
5656

5757
```toml
5858
[dependencies]
59-
tokio = { version = "1.53.1", features = ["full"] }
59+
tokio = { version = "1.53.2", features = ["full"] }
6060
```
6161
Then, on your main.rs:
6262

‎tokio/src/fs/file.rs‎

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ impl AsyncRead for File {
612612
cx: &mut Context<'_>,
613613
dst: &mut ReadBuf<'_>,
614614
) -> Poll<io::Result<()>> {
615-
ready!(crate::trace::trace_leaf());
615+
ready!(crate::trace::trace_leaf(cx));
616616

617617
let me = self.get_mut();
618618
let inner = me.inner.get_mut();
@@ -691,18 +691,32 @@ impl AsyncSeek for File {
691691
let mut buf = buf_cell.take().unwrap();
692692

693693
// Factor in any unread data from the buf
694-
if !buf.is_empty() {
694+
let extra_seek = if !buf.is_empty() {
695695
let n = buf.discard_read();
696696

697697
if let SeekFrom::Current(ref mut offset) = pos {
698-
*offset += n;
698+
match offset.checked_add(n) {
699+
Some(new_offset) => {
700+
*offset = new_offset;
701+
None
702+
}
703+
None => Some(SeekFrom::Current(n)),
704+
}
705+
} else {
706+
None
699707
}
700-
}
708+
} else {
709+
None
710+
};
701711

702712
let std = me.std.clone();
703713

704714
inner.state = State::Busy(spawn_blocking(move || {
705-
let res = (&*std).seek(pos);
715+
let res = if let Some(extra_seek) = extra_seek {
716+
(&*std).seek(extra_seek).and_then(|_| (&*std).seek(pos))
717+
} else {
718+
(&*std).seek(pos)
719+
};
706720
(Operation::Seek(res), buf)
707721
}));
708722
Ok(())
@@ -711,7 +725,7 @@ impl AsyncSeek for File {
711725
}
712726

713727
fn poll_complete(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<u64>> {
714-
ready!(crate::trace::trace_leaf());
728+
ready!(crate::trace::trace_leaf(cx));
715729
let inner = self.inner.get_mut();
716730

717731
loop {
@@ -752,7 +766,7 @@ impl AsyncWrite for File {
752766
cx: &mut Context<'_>,
753767
src: &[u8],
754768
) -> Poll<io::Result<usize>> {
755-
ready!(crate::trace::trace_leaf());
769+
ready!(crate::trace::trace_leaf(cx));
756770
let me = self.get_mut();
757771
let inner = me.inner.get_mut();
758772

@@ -832,7 +846,7 @@ impl AsyncWrite for File {
832846
cx: &mut Context<'_>,
833847
bufs: &[io::IoSlice<'_>],
834848
) -> Poll<Result<usize, io::Error>> {
835-
ready!(crate::trace::trace_leaf());
849+
ready!(crate::trace::trace_leaf(cx));
836850
let me = self.get_mut();
837851
let inner = me.inner.get_mut();
838852

@@ -912,13 +926,13 @@ impl AsyncWrite for File {
912926
}
913927

914928
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
915-
ready!(crate::trace::trace_leaf());
929+
ready!(crate::trace::trace_leaf(cx));
916930
let inner = self.inner.get_mut();
917931
inner.poll_flush(cx)
918932
}
919933

920934
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
921-
ready!(crate::trace::trace_leaf());
935+
ready!(crate::trace::trace_leaf(cx));
922936
self.poll_flush(cx)
923937
}
924938
}
@@ -1132,7 +1146,7 @@ impl Inner {
11321146
}
11331147

11341148
fn poll_complete_inflight(&mut self, cx: &mut Context<'_>) -> Poll<()> {
1135-
ready!(crate::trace::trace_leaf());
1149+
ready!(crate::trace::trace_leaf(cx));
11361150
match self.poll_flush(cx) {
11371151
Poll::Ready(Err(e)) => {
11381152
self.last_write_err = Some(e.kind());

‎tokio/src/fs/file/tests.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,3 +976,39 @@ fn busy_file_seek_error() {
976976
let mut t = task::spawn(file.seek(SeekFrom::Start(0)));
977977
assert_ready_err!(t.poll());
978978
}
979+
980+
#[test]
981+
fn incomplete_read_followed_by_overflowing_relative_seek() {
982+
let mut file = MockFile::default();
983+
let mut seq = Sequence::new();
984+
file.expect_inner_read()
985+
.once()
986+
.in_sequence(&mut seq)
987+
.returning(|buf| {
988+
buf[0..HELLO.len()].copy_from_slice(HELLO);
989+
Ok(HELLO.len())
990+
});
991+
file.expect_inner_seek()
992+
.once()
993+
.in_sequence(&mut seq)
994+
.with(eq(SeekFrom::Current(-(HELLO.len() as i64))))
995+
.returning(|_| Ok(0));
996+
file.expect_inner_seek()
997+
.once()
998+
.in_sequence(&mut seq)
999+
.with(eq(SeekFrom::Current(i64::MIN)))
1000+
.returning(|_| Err(io::ErrorKind::InvalidInput.into()));
1001+
1002+
let mut file = File::from_std(file);
1003+
let mut buf = [0; 32];
1004+
1005+
let mut t = task::spawn(file.read(&mut buf));
1006+
assert_pending!(t.poll());
1007+
1008+
pool::run_one();
1009+
1010+
let mut t = task::spawn(file.seek(SeekFrom::Current(i64::MIN)));
1011+
assert_pending!(t.poll());
1012+
pool::run_one();
1013+
assert_ready_err!(t.poll());
1014+
}

‎tokio/src/io/blocking.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,10 @@ cfg_io_uring! {
346346
/// for the kernel to write into.
347347
pub(crate) fn prepare_uring_read(&mut self, max_buf_size: usize) -> (*mut u8, u32) {
348348
assert!(self.is_empty());
349+
let max_buf_size = cmp::min(max_buf_size, u32::MAX as usize);
349350
self.buf.reserve(max_buf_size);
350351
let spare = self.buf.spare_capacity_mut();
351-
let len = std::cmp::min(spare.len(), max_buf_size);
352+
let len = cmp::min(spare.len(), max_buf_size);
352353
let ptr = spare.as_mut_ptr().cast::<u8>();
353354
(ptr, len as u32)
354355
}

‎tokio/src/io/uring/read.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ pub(crate) trait ReadBuffer: Send + 'static {
2424

2525
impl ReadBuffer for Vec<u8> {
2626
fn uring_read_prepare(&mut self, max_len: usize) -> (*mut u8, u32) {
27-
assert!(self.spare_capacity_mut().len() >= max_len);
27+
let len = u32::try_from(max_len).unwrap_or(u32::MAX);
28+
assert!(self.spare_capacity_mut().len() >= len as usize);
2829
let ptr = self.spare_capacity_mut().as_mut_ptr().cast();
29-
(ptr, max_len as u32)
30+
(ptr, len)
3031
}
3132

3233
unsafe fn uring_read_complete(&mut self, n: u32) {

‎tokio/src/io/util/copy.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl CopyBuffer {
9090
R: AsyncRead + ?Sized,
9191
W: AsyncWrite + ?Sized,
9292
{
93-
ready!(crate::trace::trace_leaf());
93+
ready!(crate::trace::trace_leaf(cx));
9494
#[cfg(any(
9595
feature = "fs",
9696
feature = "io-std",

0 commit comments

Comments
 (0)