Stream: git-wasmtime

Topic: wasmtime / PR #15144 Expose the `LinearMemory` instance f...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 15:27):

V0ldek requested wasmtime-core-reviewers for a review on PR #15144.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 15:27):

V0ldek removed the review request for wasmtime-core-reviewers from PR #15144.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 15:27):

V0ldek opened PR #15144 from V0ldek:v0ldek/expose-linear-memory to bytecodealliance:main:

Currently, when a custom MemoryCreator is supplied, it creates memory instances when a module is instantiated, but there is no way for user code to access that instance. One can work around this issue with rather clumsy code around a creator that inspects what it returns during a Linker::instantiate call, but it is very brittle.

This is useful for extracting some properties of the created memory. As an example, in AnyBlox, we need to know the length of the external data that we attach via a map into the linear memory segment. With this the creator can also assign unique IDs to created memory that can then be inspected from the outside for things like caching and custom pooling.

The proposal is to simply expose the instance from the store. After #14885, LinearMemory extends Any, so we can expose a linear_memory function that extracts the inner box and upcasts the reference to a concrete M type. This makes it so that only custom implementors providing their own LinearMemory impl can access it this way and aware of the safety implications. Internal wasmtime implementations remain inaccessible from the public. The alternative was to expose a &dyn LinearMemory directly, but I feel like a) this increases the public API surface significantly, since anyone would be able to access the internal wasmtime memory instances, and b) would be pretty useless if you didn't know and downcast to the concrete type anyway.

Safety implications are that accessing a reference to the memory while it is attached to a module could result in unsoundness if the user implements interior mutability on the memory and uses it incorrectly. However, the public contract remains tight: obtaining a reference to the memory borrows the store, so the ref cannot be held across actual runtime of the wasm module.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 15:27):

V0ldek requested cfallin for a review on PR #15144.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 16:21):

:thumbs_up: alexcrichton submitted PR review:

Nice idea :+1:

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 16:21):

alexcrichton added PR #15144 Expose the LinearMemory instance from the store. to the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 16:58):

:check: alexcrichton merged PR #15144.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 16:58):

alexcrichton removed PR #15144 Expose the LinearMemory instance from the store. from the merge queue


Last updated: Nov 19 2026 at 20:05 UTC