Skip to content

Preserve buffer order in Chain::chunks_vectored - #855

Open
RanaPriyansh wants to merge 1 commit into
tokio-rs:masterfrom
RanaPriyansh:fix/chain-vectored-order-701
Open

RanaPriyansh wants to merge 1 commit into
tokio-rs:masterfrom
RanaPriyansh:fix/chain-vectored-order-701

Conversation

@RanaPriyansh

Copy link
Copy Markdown

Fixes #701.

Chain::chunks_vectored can expose the second buffer before all bytes from the first buffer. For example, a valid partial buffer can return hworld when hello is chained to world.

Append second-buffer slices only when the first-buffer slices cover all its remaining bytes. Complete buffers retain vectored reads across both buffers.

The regression checks that each vectored read returns a logical prefix. Tests also cover repeated reads with advancement, complete buffers, empty buffers, empty and single-slot destinations, and nested chains.

Validation: cargo fmt --all --check and ci/test-stable.sh test pass on Rust 1.97 with RUSTFLAGS=-Dwarnings. The stable script covers default, individual, optional, and all features. It includes the adjacent buffer and take tests.

MSRV 1.57, pinned nightly, Miri, Loom, sanitizers, and other platform checks were not run locally. This contribution was prepared with AI assistance.

@RanaPriyansh
RanaPriyansh force-pushed the fix/chain-vectored-order-701 branch from 095f318 to eb6f563 Compare September 24, 2026 09:45

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buf::chunks_vectored() is wrong if chunk() isn't the whole buf

1 participant