Stream: git-wasmtime

Topic: wasmtime / PR #13061 Fix: asyncReadStream worker never ex...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 12 2026 at 13:12):

jedisct1 opened PR #13061 from dip-proto:async-readstream-eof-loop to bytecodealliance:main:

SUMMARY
AsyncReadStream::new keeps its background read task alive after the wrapped reader reaches EOF, so closed streams continue looping instead of terminating the worker.

PROVENANCE
This exploration and report were automatically generated by the Swival Security Scanner (https://swival.dev).

PRECONDITIONS

PROOF

  1. AsyncReadStream::new spawns a background task that loops forever around reader.read_buf(&mut buf).await in crates/wasi/src/p2/pipe.rs:162.
  2. When the wrapped reader reaches EOF, the Ok(nbytes) if nbytes == 0 arm sends Err(StreamError::Closed) through the channel in crates/wasi/src/p2/pipe.rs:168.
  3. After that send succeeds, execution falls through to the loop tail. The only terminating condition is if sent.is_err() { break; } in crates/wasi/src/p2/pipe.rs:176, which does not fire when the receiver is still alive.
  4. The next iteration reads EOF again and repeats the same send, so the task never terminates on its own.
  5. This is reachable today because the test helpers instantiate AsyncReadStream with EOF-producing readers such as tokio::io::empty() and finite pipe readers in crates/wasi/src/p2/pipe.rs:380 and crates/wasi/src/p2/pipe.rs:435.

WHY THIS IS A REAL BUG
The worker is documented and structured as the asynchronous bridge for a single stream. Once EOF is observed, the stream is permanently closed, so continuing to poll the underlying reader and resignal closure is incorrect behavior, not a stylistic choice.

PATCH RATIONALE
The patch makes EOF a terminal condition by breaking the loop after a successful closed notification, while preserving existing behavior for normal data delivery, receiver shutdown, and I/O errors. It is local to the loop that mishandles EOF and does not change unrelated stream semantics.

RESIDUAL RISK
None

view this post on Zulip Wasmtime GitHub notifications bot (Apr 12 2026 at 13:12):

jedisct1 requested wasmtime-wasi-reviewers for a review on PR #13061.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 12 2026 at 16:56):

github-actions[bot] added the label wasi on PR #13061.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 12 2026 at 17:40):

jedisct1 closed without merge PR #13061.


Last updated: Apr 13 2026 at 00:25 UTC