Fix another case of Miri unsoundness #11056
Merged
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.
This commit fixes another issue we've discovered in the wasip3 prototyping repository about a code pattern in wasm which Miri flags as un-sound. Specifically what happened was:
Invocation of WebAssembly went through
VMFuncRef::array_call
which takes a&self
parameter.Inside of WebAssembly though a
ref.func
instruction, or anything else that references the original exported function, will re-initialize theVMFuncRef
which writes the&self
up the stack, which is not sound.Fixing this required changing the signature of
array_call
from&self
tome: NonNull<VMFuncRef>
, and the signature was alreadyunsafe
so this is a new unsafe contract for that signature.In fixing this, however, it was discovered that a mistake was made in #10943 where some internal functions for re-initializing a
VMFuncRef
relied on the previous signature of&mut self
but that PR switche to&self
. This PR corrects these signatures toPin<&mut Self>
and then plumbs around the necessary changes, notably causing some refactoring in component-related bits.