Repository navigation
Conversation
With copy-on-write memory initialization disabled (or when a module's data segments can't be made into a static image), the module startup function initializes every data segment, loading each segment's base and length out of the `VMContext`. Each of those loads got an alias region keyed by its own `VMContext` offset, so a module with more than ~32k data segments needs more distinct `MemFlags` than a Cranelift function can hold and compilation panics with `MemFlagsSetOverflow`. Modules compiled by Go routinely have tens of thousands of data segments. Key the region on the start of the `runtime_data_bases` and `runtime_data_lengths` arrays instead, giving each array a single region. This is only ever coarser than before. On `main` this is covered by bytecodealliance#14253, which bounds the number of alias regions in general. Claude-Session: https://claude.ai/code/session_01EHmbaDcapmSnyJtjfAGMtR
Its only caller was `store_vmctx_runtime_data_length`, which now picks its alias region from the start of the runtime-data lengths array. Claude-Session: https://claude.ai/code/session_01EHmbaDcapmSnyJtjfAGMtR
Member
|
@vuldin could you also send a PR adding release notes to the |
alexcrichton
pushed a commit
that referenced
this pull request
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! We're moving Redpanda's data transforms onto the 48 LTS line, and on 48.0.7 compiling a typical Go guest panics:
from
inst_builder.rs(load), insideModule::new. We embed Wasmtime through the C API, so that panic can't unwind and aborts the host process.With copy-on-write memory init off (we have to run with
memory_init_cow(false)because guest memory comes from our own allocator), the module startup function initializes every data segment, and for each one it loads the segment's base and length out of theVMContext.vmctx_load/vmctx_storekey the alias region on theVMContextoffset, so every segment adds two distinct regions, and so two distinctMemFlags, to that one function. Past ~32k data segments that's more than theu16MemFlagsindex allows. Go guests routinely have that many (the two that hit it for us have ~43K and ~46K data segments).This PR keys the region for the
runtime_data_basesandruntime_data_lengthsarrays on the start of each array instead of on each element. It's only ever coarser than before, and those three helpers are the only accessors of the two arrays, so nothing else touches the same memory under a different region.On
mainthis is already covered by #14253 (bounding alias regions to 256), which went into 49. That one depends on #14230 and is a much bigger change, so this is a narrower fix for the 48 branch. Another option is to backport #14253 + #14230 instead if you'd rather keep 48 closer tomain.The test compiles and instantiates a module with 40K data segments and
memory_init_cow(false). I haven't run Wasmtime's own test suite locally. In Redpanda the same change, applied to 48.0.7, takes our two Go-guest tests from aborting on every run to passing.