Stream: git-wasmtime

Topic: wasmtime / PR #14871 Allow resource handles to move betwe...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2026 at 18:55):

jrandolf edited PR #14871.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2026 at 18:55):

jrandolf has marked PR #14871 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2026 at 18:55):

jrandolf requested cfallin for a review on PR #14871.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2026 at 18:55):

jrandolf removed the review request for wasmtime-core-reviewers from PR #14871.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2026 at 18:55):

jrandolf requested wasmtime-core-reviewers for a review on PR #14871.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2026 at 18:58):

jrandolf edited PR #14871:

Using a resource handle with a different static type than the one it was created with trapped, even when both static types are bound to the same resource type at runtime. The canonical ABI compares the runtime types (h.rt is not t.rt), so this makes Wasmtime compare them too when the static types differ. Equal static types work as before.

For example, this fixes passing a handle between two imports of the same interface whose resources the host defines with the same ResourceType, and between two imports of a subcomponent that were given the same resource. Handles of different runtime types still trap, with a new message.

Closes #14861

<details>
<summary>LLM summary of the changes</summary>

The problem

Each entry in a component instance's handle table records the static resource type (TypeResourceTableIndex) it was created with, and TypedResource::rep trapped whenever a handle was used with any other static type. The canonical ABI instead checks h.rt is not t.rt, comparing runtime resource types. So a handle has to be accepted wherever the static types differ but are bound to the same runtime type. Two cases hit this:

The check (vm/component/resources.rs, vm/component/handle_table.rs)

Plumbing (vm/component.rs, func/options.rs, store.rs)

ResourceTables::guest now also carries the instance's runtime resource types. A new ComponentInstance::instance_states_and_resource_types returns them along with the instance states and types, and the two places that build ResourceTables use it. instance_states is now a wrapper around it.

Error message

ResourceTypeMismatch used to say which kind of resource was expected and found, which was wrong for host resources stored in a component's table. It now says "handle index N used with the wrong type, found a handle to a different resource type". The upstream component-model tests check the old wording, so crates/wast maps it to the new one, as it already does for a few other spec messages. resources.wast and the mismatch_intrinsics test are updated to the new wording.

Destructors

The canonical ABI ties a destructor to the runtime resource type, but in Wasmtime each LinkerInstance::resource definition has its own destructor. When a handle created through one import is dropped through another, the destructor of the import it's dropped through runs. LinkerInstance::resource documents this, and the named_imports docs of bindgen! say that resources are shared between imports and that the id passed to a method, including drop, identifies the import being called.

Behavior change

This only makes programs work that trapped before. Handles of different runtime types, such as guest resources of different instances or different host types, still trap.

Tests

</details>

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2026 at 20:55):

jrandolf commented on PR #14871:

We don't have a concrete need for this, so I'm closing it.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2026 at 20:55):

:cross_mark: jrandolf closed without merge PR #14871.


Last updated: Oct 31 2026 at 23:03 UTC