pchickey opened PR #6973 from bytecodealliance:pch/adapter_eliminate_state_with_mut
to bytecodealliance:main
:
There is no need to get exclusive access to State:
- All mutation of State and Descriptors is handled internally with cells.
descriptors_mut
does not need exclusive access to State, and eliminating that constraint means we can trivially shorten all uses ofwith_mut
towith
.- recursive access to State is required for implementing the cabi_realloc functions. These functions do not need exclusive access to State, but if another call has already taken an exclusive borrow, realloc will trap.
I recently found a bug that would occur if
path_open
is the first call into the adapter, the State will be borrowed exclusively anddescriptors_mut
will initialize the descriptors by calling out to get the preopens. Because preopens are a list, the runtime needs to call cabi_realloc to return them, and that call will fail where cabi_import_realloc tries to borrow the exclusively- borrowed State.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
pchickey requested wasmtime-core-reviewers for a review on PR #6973.
pchickey requested fitzgen for a review on PR #6973.
pchickey edited PR #6973:
There is no need to get exclusive access to State:
- All mutation of State and Descriptors is handled internally with cells.
descriptors_mut
does not need exclusive access to State, and eliminating that constraint means we can trivially shorten all uses ofwith_mut
towith
.- recursive access to State is required for implementing the cabi_realloc functions. These functions do not need exclusive access to State, but if another call has already taken an exclusive borrow, realloc will trap.
This changes fixes a bug that would occur if
path_open
is the first call into the adapter, the State will be borrowed exclusively anddescriptors_mut
will initialize the descriptors by calling out to get the preopens. Because preopens are a list, the runtime needs to call cabi_realloc to return them, and that call will fail where cabi_import_realloc tries to borrow the exclusively- borrowed State.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton submitted PR review.
pchickey merged PR #6973.
Last updated: Dec 23 2024 at 12:05 UTC