wiggle: copy guest strings from shared memory #5475
Merged
alexcrichton merged 2 commits intobytecodealliance:mainfrom Jan 4, 2023
Merged
wiggle: copy guest strings from shared memory #5475alexcrichton merged 2 commits intobytecodealliance:mainfrom
alexcrichton merged 2 commits intobytecodealliance:mainfrom
Conversation
Member
Author
|
Depends on #5471; review that PR first! |
9c343b3 to
ab11505
Compare
Subscribe to Label Actioncc @kubkon DetailsThis issue or pull request has been labeled: "wasi"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
ab11505 to
cef93fe
Compare
alexcrichton
approved these changes
Jan 3, 2023
Along the same lines as bytecodealliance#5471, this change adds a new smart pointer, `GuestStrCow`, to copy the string bytes over from Wasm memory to the host when the string is found in shared memory. This is necessary to maintain Rust guarantees: with shared memory, the bytes backing a `GuestStr` could be altered by another thread and this would invalidate the assumption that we can dereference at any point to `&str`. `GuestStrCow` is essentially a wrapper around `GuestStr` when the memory is not shared but copies the memory region into a `String` when the memory is shared. This change updates the uses of Wiggle strings in both wasi-common and wasi-crypto.
cef93fe to
4690bfb
Compare
alexcrichton
approved these changes
Jan 4, 2023
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.
Along the same lines as #5471, this change adds a new smart pointer,
GuestStrCow, to copy the string bytes over from Wasm memory to thehost when the string is found in shared memory. This is necessary to
maintain Rust guarantees: with shared memory, the bytes backing a
GuestStrcould be altered by another thread and this would invalidatethe assumption that we can dereference at any point to
&str.GuestStrCowis essentially a wrapper aroundGuestStrwhen the memoryis not shared but copies the memory region into a
Stringwhen thememory is shared.