Skip to content

Avoid dangling references to exited threads - #13926

Merged
alexcrichton merged 2 commits into
bytecodealliance:mainfrom
alexcrichton:dangling-thread-fix
Jul 21, 2026
Merged

alexcrichton merged 2 commits into
bytecodealliance:mainfrom
alexcrichton:dangling-thread-fix

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This commit is a refactor of the HostTask::caller field to no longer refer to a QualifiedThreadId. This is not valid to store within a HostTask because threads can exit while a host task is still running. More generally a caller field isn't valid to store because tasks can exit without blocking on callees, but that refactoring is left for another day.

Otherwise most of this commit is juggling state and moving things around now that caller is no longer present. I've attempted to explicitly pass it around in a few places and notably delineate boundaries of tasks entering/exiting a bit more clearly in a few locations. This commit also surface WebAssembly/component-model#678 which is something we'll have to address in the future as well, and now it's got a FIXME for the primary location of where the chosen task to lower with is suspect.

Closes #13890

This commit is a refactor of the `HostTask::caller` field to no longer
refer to a `QualifiedThreadId`. This is not valid to store within a
`HostTask` because threads can exit while a host task is still running.
More generally a `caller` field isn't valid to store because tasks can
exit without blocking on callees, but that refactoring is left for
another day.

Otherwise most of this commit is juggling state and moving things around
now that `caller` is no longer present. I've attempted to explicitly
pass it around in a few places and notably delineate boundaries of tasks
entering/exiting a bit more clearly in a few locations. This commit also
surface WebAssembly/component-model#678 which is something we'll have to
address in the future as well, and now it's got a `FIXME` for the
primary location of where the chosen task to lower with is suspect.

Closes bytecodealliance#13890
@alexcrichton
alexcrichton requested a review from dicej July 21, 2026 18:50
@alexcrichton
alexcrichton requested a review from a team as a code owner July 21, 2026 18:50
@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Jul 21, 2026
@alexcrichton
alexcrichton added this pull request to the merge queue Jul 21, 2026
Merged via the queue into bytecodealliance:main with commit f277eba Jul 21, 2026
53 checks passed
@alexcrichton
alexcrichton deleted the dangling-thread-fix branch July 21, 2026 22:15
yagehu referenced this pull request in yagehu/wasmtime-x Jul 26, 2026
* Avoid dangling references to exited threads

This commit is a refactor of the `HostTask::caller` field to no longer
refer to a `QualifiedThreadId`. This is not valid to store within a
`HostTask` because threads can exit while a host task is still running.
More generally a `caller` field isn't valid to store because tasks can
exit without blocking on callees, but that refactoring is left for
another day.

Otherwise most of this commit is juggling state and moving things around
now that `caller` is no longer present. I've attempted to explicitly
pass it around in a few places and notably delineate boundaries of tasks
entering/exiting a bit more clearly in a few locations. This commit also
surface WebAssembly/component-model#678 which is something we'll have to
address in the future as well, and now it's got a `FIXME` for the
primary location of where the chosen task to lower with is suspect.

Closes #13890

* Fix compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Host tasks created by guest threads that exit contain dangling references to the deleted thread

2 participants