alexcrichton opened PR #13949 from alexcrichton:reset-realloc-context to bytecodealliance:main:
This commit is an implementation of WebAssembly/component-model#680 which is a semantic change for invocations of the
realloccanonical ABI option. Previously when this function was invoked the configured context-storage was whatever happened to run last in the store and in general wasn't well-defined. Additionally the context of the thread being run in was whatever happened to run last. The goal of the upstream spec change, and this commit, is to fully define what happens in this situation. Specifically:
- Invocations of
reallocalways start withcontextslots set to 0.- The
thread.indexintrinsics, part of the component-model-threading proposal, is now no longer exempt from may-leave checks.These changes combined mean that it's not actually possible for
reallocto witness anything about its thread identity. This means that we don't actually have to allocate anything, all that's necessary is to save/restore context around invocation ofcabi_realloc.While this is a breaking change it's not expected to be observable in the ecosystem. This only affects
contextslots which are primarily only used for the WASIp3 ABI as the stack pointer and TLS base. There is no shipping WASIp3 target anywhere right now, so this breakage should not be observable.<!--
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 requested wasmtime-compiler-reviewers for a review on PR #13949.
alexcrichton requested cfallin for a review on PR #13949.
alexcrichton requested wasmtime-core-reviewers for a review on PR #13949.
:thumbs_up: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Do we need a drop-guard to restore the context if an error is returned (e.g. the
bail!above), or are those always trap-cases I guess?
alexcrichton updated PR #13949.
alexcrichton updated PR #13949.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
We should be good in this case because once a component traps everything internally is inaccessible and no longer able to be seen by a guest. There's a fair number of locations in
concurrent.rsthat do this as well (don't restore on trap/panic) as well. I've added a comment now to that effect though for future readers
alexcrichton has enabled auto merge for PR #13949.
alexcrichton added PR #13949 Configure async task context on realloc calls to the merge queue.
github-merge-queue[bot] removed PR #13949 Configure async task context on realloc calls from the merge queue.
alexcrichton commented on PR #13949:
Heh well @dicej maybe your Windows-specific failure wasn't Windows-specific after all (failing test on macOS)
alexcrichton added PR #13949 Configure async task context on realloc calls to the merge queue.
:check: alexcrichton merged PR #13949.
alexcrichton removed PR #13949 Configure async task context on realloc calls from the merge queue.
Last updated: Jul 29 2026 at 05:03 UTC