clear descriptor table in __wasilibc_reset_preopens#776
Merged
dicej merged 1 commit intoWebAssembly:mainfrom Mar 23, 2026
Merged
clear descriptor table in __wasilibc_reset_preopens#776dicej merged 1 commit intoWebAssembly:mainfrom
__wasilibc_reset_preopens#776dicej merged 1 commit intoWebAssembly:mainfrom
Conversation
c7272ec to
abda872
Compare
alexcrichton
approved these changes
Mar 21, 2026
e705522 to
4fb1d89
Compare
The original intention of `__wasilibc_reset_preopens` was to clear the stdio state as the last step of Wizer-style pre-initialization since none of the handles would be valid when the snapshot is resumed. In earlier versions of `wasi-libc`, which didn't have native p2 or p3 support for stdio or file I/O, resetting the WASIp1 state was sufficient; the `wasi_snapshot_preview1` adapter took care of emulating p1 in terms of p2. However, now that `wasi-libc` has native support for p2 and p3, we need to also reset the descriptor table. At this point, the name `__wasilibc_reset_preopens` is a bit misleading for p2+ since we're clearing more than just the preopens, but changing the name would break tools which use it, so probably not worth the trouble.
4fb1d89 to
a74116f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The original intention of
__wasilibc_reset_preopenswas to clear the stdio state as the last step of Wizer-style pre-initialization since none of the handles would be valid when the snapshot is resumed. In earlier versions ofwasi-libc, which didn't have native p2 or p3 support for stdio or file I/O, resetting the WASIp1 state was sufficient; thewasi_snapshot_preview1adapter took care of emulating p1 in terms of p2. However, now thatwasi-libchas native support for p2 and p3, we need to also reset the descriptor table.At this point, the name
__wasilibc_reset_preopensis a bit misleading for p2+ since we're clearing more than just the preopens, but changing the name would break tools which use it, so probably not worth the trouble.