-
Notifications
You must be signed in to change notification settings - Fork 1.5k
More table safety improvements #11255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexcrichton
merged 3 commits into
bytecodealliance:main
from
alexcrichton:more-safer-tables
Jul 17, 2025
Merged
More table safety improvements #11255
alexcrichton
merged 3 commits into
bytecodealliance:main
from
alexcrichton:more-safer-tables
Jul 17, 2025
Conversation
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
This is some more progress on bytecodealliance#11179 aimed at improving the safety of management of tables internally within Wasmtime: * `Instance::table_index` is removed as it can be replaced with data stored directly in the `VMTableImport` now. * `Instance::get_table` now returns `&mut Table` * `Instance::get_defined_table_with_lazy_init` now returns `&mut Table` * `Instance::with_defined_table_index_and_instance` now directly returns `DefinedTableIndex` plus `Pin<&mut Instance>`, codifying the ability to "laterally move" between instances. * `Instance::table_init_segment` was refactored to "take" the tables during initialization and replace them afterwards, resolving the split borrow issue and removing an `unsafe` block in the function. cc bytecodealliance#11179
pchickey
approved these changes
Jul 16, 2025
This commit fixes an issue in the previous commit with respect to Miri and Stacked Borrows. This does so by improving the safety of the `Table::copy`-related functions to all work mostly on safe code rather than unsafe references. Some minor amount of unsafety is still present but it is now clearly documented and easier to verify.
Member
Author
|
The Miri violation of stacked borrows is I believe legitimate, so I've added a new commit which improves the safety situation around |
Member
Author
pchickey
approved these changes
Jul 17, 2025
fitzgen
added a commit
to fitzgen/wasmtime
that referenced
this pull request
Jul 24, 2025
The `match` makes the cases a lot more clear IMO, and additionally the conditions asserted in each branch become trivially obvious (they are exactly what was matched upon for their associated branch) so I removed them. I also made some minor copy-edit tweaks to some comments while I was here. This would have just been a nitpick review comment on bytecodealliance#11255 but I was traveling and didn't get a chance to leave review comments in a reasonable amount of time, so instead I am just fixing them up myself in this follow up.
This was referenced Jul 24, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jul 24, 2025
The `match` makes the cases a lot more clear IMO, and additionally the conditions asserted in each branch become trivially obvious (they are exactly what was matched upon for their associated branch) so I removed them. I also made some minor copy-edit tweaks to some comments while I was here. This would have just been a nitpick review comment on #11255 but I was traveling and didn't get a chance to leave review comments in a reasonable amount of time, so instead I am just fixing them up myself in this follow up.
bongjunj
pushed a commit
to prosyslab/wasmtime
that referenced
this pull request
Oct 20, 2025
* More table safety improvements This is some more progress on bytecodealliance#11179 aimed at improving the safety of management of tables internally within Wasmtime: * `Instance::table_index` is removed as it can be replaced with data stored directly in the `VMTableImport` now. * `Instance::get_table` now returns `&mut Table` * `Instance::get_defined_table_with_lazy_init` now returns `&mut Table` * `Instance::with_defined_table_index_and_instance` now directly returns `DefinedTableIndex` plus `Pin<&mut Instance>`, codifying the ability to "laterally move" between instances. * `Instance::table_init_segment` was refactored to "take" the tables during initialization and replace them afterwards, resolving the split borrow issue and removing an `unsafe` block in the function. cc bytecodealliance#11179 * Improve safety of `Table::copy` This commit fixes an issue in the previous commit with respect to Miri and Stacked Borrows. This does so by improving the safety of the `Table::copy`-related functions to all work mostly on safe code rather than unsafe references. Some minor amount of unsafety is still present but it is now clearly documented and easier to verify. * Fix tests
bongjunj
pushed a commit
to prosyslab/wasmtime
that referenced
this pull request
Oct 20, 2025
The `match` makes the cases a lot more clear IMO, and additionally the conditions asserted in each branch become trivially obvious (they are exactly what was matched upon for their associated branch) so I removed them. I also made some minor copy-edit tweaks to some comments while I was here. This would have just been a nitpick review comment on bytecodealliance#11255 but I was traveling and didn't get a chance to leave review comments in a reasonable amount of time, so instead I am just fixing them up myself in this follow up.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cranelift
Issues related to the Cranelift code generator
wasmtime:api
Related to the API of the `wasmtime` crate itself
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 is some more progress on #11179 aimed at improving the safety of management of tables internally within Wasmtime:
Instance::table_indexis removed as it can be replaced with data stored directly in theVMTableImportnow.Instance::get_tablenow returns&mut TableInstance::get_defined_table_with_lazy_initnow returns&mut TableInstance::with_defined_table_index_and_instancenow directly returnsDefinedTableIndexplusPin<&mut Instance>, codifying the ability to "laterally move" between instances.Instance::table_init_segmentwas refactored to "take" the tables during initialization and replace them afterwards, resolving the split borrow issue and removing anunsafeblock in the function.Closes #11179