Skip to content

wasip3: Fix trapping on read/write after shutdown#790

Merged
alexcrichton merged 2 commits intoWebAssembly:mainfrom
alexcrichton:improve-shutdown
Apr 21, 2026
Merged

wasip3: Fix trapping on read/write after shutdown#790
alexcrichton merged 2 commits intoWebAssembly:mainfrom
alexcrichton:improve-shutdown

Conversation

@alexcrichton
Copy link
Copy Markdown
Collaborator

On shutdown the streams are closed so the __wasilibc_{read,write} functions would end up trapping when passing a zero handle to the runtime. This commit fixes this by adding checks to these function and deferring to EOF handling in such a situation.

Additionally the write EOF handler for TCP is updated to return -1 and set errno to EPIPE rather than returning 0.

On shutdown the streams are closed so the `__wasilibc_{read,write}`
functions would end up trapping when passing a zero handle to the
runtime. This commit fixes this by adding checks to these function and
deferring to EOF handling in such a situation.

Additionally the write EOF handler for TCP is updated to return -1 and
set errno to `EPIPE` rather than returning 0.
@alexcrichton alexcrichton requested a review from dicej April 21, 2026 18:21
@alexcrichton alexcrichton merged commit 6024e11 into WebAssembly:main Apr 21, 2026
33 checks passed
@alexcrichton alexcrichton deleted the improve-shutdown branch April 21, 2026 18:55
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.

2 participants