Remove unsoundness of widening store borrows #11481
Merged
alexcrichton merged 2 commits intobytecodealliance:mainfrom Aug 21, 2025
Merged
Remove unsoundness of widening store borrows #11481alexcrichton merged 2 commits intobytecodealliance:mainfrom
alexcrichton merged 2 commits intobytecodealliance:mainfrom
Conversation
Member
Author
dicej
approved these changes
Aug 20, 2025
| ); | ||
| store.on_fiber(|store| self.instantiate_impl(store)).await? | ||
| pub async fn instantiate_async(&self, store: impl AsContextMut<Data = T>) -> Result<Instance> { | ||
| self._instantiate(store).await |
Contributor
There was a problem hiding this comment.
Why do we not need an assert!(store.0.async_support()) here anymore?
Member
Author
There was a problem hiding this comment.
A good question! That's part of the previous commits and Nick was also curious here, with some rationale in my response over there
This commit removes preexisting unsoundness in Wasmtime where a `&mut StoreOpaque` borrow was "widened" into encompassing the limiter on the `T` in `StoreInner<T>`, for example, by using the self-pointer located in an instance or the store. This fix is done by threading `&mut StoreOpaque` as a parameter separately from a `StoreResourceLimiter`. This means that various callers now take a new `Option<&mut StoreResourceLimiter<'_>>` parameter in various locations. Closes bytecodealliance#11409
20ee87b to
1288134
Compare
bongjunj
pushed a commit
to prosyslab/wasmtime
that referenced
this pull request
Oct 20, 2025
* Remove unsoundness of widening store borrows This commit removes preexisting unsoundness in Wasmtime where a `&mut StoreOpaque` borrow was "widened" into encompassing the limiter on the `T` in `StoreInner<T>`, for example, by using the self-pointer located in an instance or the store. This fix is done by threading `&mut StoreOpaque` as a parameter separately from a `StoreResourceLimiter`. This means that various callers now take a new `Option<&mut StoreResourceLimiter<'_>>` parameter in various locations. Closes bytecodealliance#11409 * Fix gc-less build
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.
This commit removes preexisting unsoundness in Wasmtime where a
&mut StoreOpaqueborrow was "widened" into encompassing the limiter onthe
TinStoreInner<T>, for example, by using the self-pointerlocated in an instance or the store. This fix is done by threading
&mut StoreOpaqueas a parameter separately from aStoreResourceLimiter. This means that various callers now take a newOption<&mut StoreResourceLimiter<'_>>parameter in various locations.Closes #11409