Skip to content

wasi:io: enforce the check-write permit in the remaining output streams - #14966

Open
xia-chao wants to merge 1 commit into
bytecodealliance:mainfrom
xia-chao:wasi-write-permit-4streams
Open

xia-chao wants to merge 1 commit into
bytecodealliance:mainfrom
xia-chao:wasi-write-permit-4streams

Conversation

@xia-chao

@xia-chao xia-chao commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Dropped the cli tracking. The c-api, sink and file streams now trap when a write exceeds the check-write permit, with one shared budget.

@xia-chao
xia-chao requested review from a team as code owners October 23, 2026 17:24
@xia-chao
xia-chao requested review from dicej and rvolosatovs and removed request for a team October 23, 2026 17:24
@github-actions github-actions Bot added wasi Issues pertaining to WASI wasmtime:c-api Issues pertaining to the C API. labels Oct 23, 2026
Comment thread crates/c-api/src/wasi.rs Outdated
impl wasmtime_wasi::p2::OutputStream for CustomOutputStream {
fn write(&mut self, bytes: Bytes) -> Result<(), StreamError> {
// Keep in sync with the permit reported by `check_write` below.
const WRITE_BUDGET: usize = 64 * 1024;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this const should be hoisted out to the parent scope, and used in the check_write method as well

}
}

enum StdioOutputStream {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that it is worthwhile for us to track whether check_write has issued the permit, we just need to trap when write exceeds the permitted size, which it already does. So, all of these changes to the cli streams should be thrown away - they already obey the spec from my reading as well as what we enforce in other streams.

@pchickey

Copy link
Copy Markdown
Contributor

This PR is borderline on my radar of needing more careful human review before submission - the changes to c-api and pipe are fundamentally completely different to those proposed in the changes to the stdout/stderr streams, and it would have been nice if you had caught that before submitting.

The c-api, sink and file streams accepted writes larger than the
check-write budget; reject them and share one budget constant.
@xia-chao
xia-chao force-pushed the wasi-write-permit-4streams branch from 25c1fa9 to baa508b Compare October 24, 2026 08:07
@xia-chao

Copy link
Copy Markdown
Contributor Author

Noted.

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

wasi Issues pertaining to WASI wasmtime:c-api Issues pertaining to the C API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants