Skip to content

[48.0.x] Use one alias region per runtime-data array - #15050

Merged
fitzgen merged 2 commits into
bytecodealliance:release-48.0.0from
vuldin:release-48-runtime-data-alias-region
Oct 28, 2026
Merged

fitzgen merged 2 commits into
bytecodealliance:release-48.0.0from
vuldin:release-48-runtime-data-alias-region

Conversation

@vuldin

@vuldin vuldin commented Oct 28, 2026

Copy link
Copy Markdown

Hi! We're moving Redpanda's data transforms onto the 48 LTS line, and on 48.0.7 compiling a typical Go guest panics:

called `Result::unwrap()` on an `Err` value: MemFlagsSetOverflow

from inst_builder.rs (load), inside Module::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 the VMContext. vmctx_load/vmctx_store key the alias region on the VMContext offset, so every segment adds two distinct regions, and so two distinct MemFlags, to that one function. Past ~32k data segments that's more than the u16 MemFlags index 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_bases and runtime_data_lengths arrays 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 main this 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 to main.

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.

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
@vuldin
vuldin requested review from a team as code owners October 28, 2026 19:31
@vuldin
vuldin requested review from fitzgen and removed request for a team October 28, 2026 19:31
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

@fitzgen fitzgen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

@fitzgen
fitzgen merged commit 8be1a51 into bytecodealliance:release-48.0.0 Oct 28, 2026
191 checks passed
@fitzgen

fitzgen commented Oct 28, 2026

Copy link
Copy Markdown
Member

@vuldin could you also send a PR adding release notes to the release-48.0.0 branch's RELEASES.md for this change? Thanks!

alexcrichton pushed a commit that referenced this pull request Oct 28, 2026
q-uint pushed a commit to Swiss-Subnet/ic that referenced this pull request Nov 19, 2026
… stack (dfinity#12180)

Stacked on dfinity#12178, which is stacked on dfinity#12177. dfinity#12177 refreshes both
lock sets but holds the replica runtime back; this PR releases those
holds, except flate2 and wirm (see [Still held](#still-held)). It only
changes the lock files.

# Changes

Both `Cargo.lock` and `Cargo.Bazel.{toml,json}.lock` move to the newest
semver-compatible versions:

| Crates | From → to |
|---|---|
| wasmtime, wasmtime-environ, the `wasmtime-internal-*` crates,
pulley-interpreter, pulley-macros | 48.0.7 → 48.0.9 |
| the `cranelift-*` crates | 0.135.7 → 0.135.9 |
| regalloc2 | 0.15.2 → 0.15.3 |
| aws-lc-rs, aws-lc-sys | 1.18.1 → 1.19.0, 0.45.0 → 0.47.0 (AWS-LC 5.7.0
→ 5.12.0) |
| rustls-webpki | 0.103.16 → 0.103.17 |
| webpki-roots | 1.0.6 → 1.0.12 |
| webpki-root-certs | 1.0.6 (Cargo), 1.0.4 (Bazel) → 1.0.12 |
| rustls-pki-types | 1.14.0 (Cargo), 1.12.0 (Bazel) → 1.16.0 |
| tokio-rustls | 0.26.4 (Cargo), 0.26.0 (Bazel) → 0.26.6 |
| hyper-rustls | 0.27.7 → 0.27.10 |
| rustls-native-certs | 0.8.3 (Cargo), 0.8.0 (Bazel) → 0.8.5 |
| openssl-probe | 0.2.1 (Cargo), 0.1.5 (Bazel) → 0.2.2 |
| async-web-client | 0.6.3 → 0.6.4 |
| brotli, brotli-decompressor | 8.0.2 (Cargo), 8.0.1 (Bazel) → 8.0.4;
5.0.0 → 5.0.3 |

wasmtime stays on the 48 LTS line. aws-lc-sys and, in Bazel,
openssl-probe cross a 0.x boundary because aws-lc-rs 1.19.0 and
rustls-native-certs 0.8.5 require it.

The new versions also drop three duplicates: hyper-rustls 0.27.10 uses
rustls-platform-verifier 0.7.1, so 0.6.2 and
rustls-platform-verifier-android 0.1.1 go; async-web-client 0.6.4 uses
webpki-roots 1.0.12, so the 0.26 copy goes.

Re-resolving also changes some dependency edges of crates whose versions
stay. In the Bazel lock, quinn and quinn-udp, which the replica's QUIC
transport uses, go back from socket2 0.6.5 (as dfinity#12178 has them) to
0.5.10 (as dfinity#12177 has them); `Cargo.lock` keeps 0.6.5. Both are within
their `>=0.5, <0.7` requirement, and the next PR in the stack removes
socket2 0.5.10. The other edge changes follow the moved TLS crates, or
are Windows-only windows-sys edges.

## Still held

- **flate2** stays at 1.1.9 (Cargo) / 1.1.5 (Bazel). From 1.1.10 it
decodes with miniz_oxide 0.9, which, like zlib, rejects incomplete
Huffman trees that 0.8 accepted (miniz_oxide#190). The replica
decompresses a canister's stored `.wasm.gz` again whenever it compiles
it (`rs/embedders/src/wasm_utils/decoding.rs`), so a module that only
the old decoder accepts would stop loading after an upgrade. zlib never
produces such trees, but the upgrade needs its own PR, ideally with a
check of the gzipped modules installed on mainnet.
- **wirm** stays at 4.0.4: it instruments canister code and moves in its
own PR.

# Behaviour changes (FYI)

@dfinity/core-protocol (execution, crypto, networking), FYI
@dfinity/node for the boundary node and HostOS/GuestOS components.

- **wasmtime 48.0.8 and 48.0.9** are security patch releases. None of
their 13 advisories applies to the replica's configuration:
- GHSA-6fr9-xmw9-5352 and GHSA-xrvr-8678-5wp8 need the component model,
which we don't build.
- GHSA-43j2-gcp4-m22g, GHSA-wvgq-g5hf-6gm6, GHSA-3982-jqvv-277m and
GHSA-qw58-7h65-crq2 need Wasm GC or host-created GC values; we set
`wasm_gc(false)`.
- GHSA-rc4p-x33f-vpr2 only affects builds without the `gc` feature,
which we enable.
- GHSA-2674-w29h-wqvj needs the threads proposal enabled without the
`threads` feature; we never enable it.
- GHSA-hj27-mpw9-ff4c needs `Caller::get_module_export`, which we don't
call.
- GHSA-hmmr-87qq-258j, GHSA-h4wp-g4x3-7398, GHSA-5m8g-xhq4-4h93 and
GHSA-f8mm-ggr3-89wh are in wasmtime-wasi and wasmtime-wasi-http, which
we don't use.

48.0.8 also fixes a Cranelift compile panic when one function touches
more than ~32k data segments (bytecodealliance/wasmtime#15050).
- **webpki-roots 1.0.12** (from 1.0.6) removes 28 roots and adds 4.
Among the removed are DigiCert Global Root CA, DigiCert High Assurance
EV Root CA and GTS Root R2; ISRG Root X1/X2 (Let's Encrypt) stay. On
CloudEngine subnets the replica uses this store to authenticate the API
boundary node it fetches the NNS delegation from
(`nns_delegation_manager`). Together with **webpki-root-certs 1.0.12**,
which ic-gateway's HTTP client trusts through ic-bn-lib, this fixes
RUSTSEC-2026-0381 and RUSTSEC-2026-0383 (the `emSign ECC Root CA - G3`
root of distrusted emSign intermediates).
- **rustls-pki-types 1.16** strips a trailing dot from
`DnsName`/`ServerName`, and rejects names whose last label is `0x` or
`0X` followed only by hex digits (e.g. `example.0x1f`), which could be
read as an IPv4 address. hyper-rustls applies this to HTTPS-outcall host
names.
- **aws-lc-rs 1.19 / aws-lc-sys 0.47** update the AWS-LC crypto library
(5.7.0 → 5.12.0) used by rustls in the replica's TLS.
- **rustls-native-certs 0.8.5 / openssl-probe 0.2.2** (Bazel: from 0.8.0
/ 0.1.5) change how the system CA store is found and loaded: a fixed
Linux list instead of scanning 16 prefixes, every file in the
certificate directories (deduplicated by inode) instead of only
hash-named files, `SSL_CERT_DIR` as a `:`-separated list, and no
fallback to the system store once `SSL_CERT_FILE` or `SSL_CERT_DIR` is
set. Besides the HTTPS-outcalls adapter, this is the root store of every
reqwest client through rustls-platform-verifier, including the
orchestrator's GuestOS upgrade-image and subnet-recovery downloads and
HostOS's upgrade download. On Ubuntu-based images the same bundle loads.
- **brotli-decompressor 5.0.3**, which rustls uses for certificate
compression in node-to-node TLS, rejects streams with non-zero final
padding.
- **async-web-client 0.6.4** is the HTTP client of rustls-acme, which
ic-boundary uses through ic-bn-lib for TLS-ALPN-01. Its only change is a
new default root store (webpki-roots 1.x), which rustls-acme never uses
because it passes its own `ClientConfig`.

# Verification

Run locally on this branch:
- In the dev container, `cargo update --workspace` reports "Locking 0
packages" and `./bin/bazel-pin.sh` reports "Nothing to repin.".
- Both lock sets move the same crates to the same versions: those in the
table, plus the dropped duplicates above.
- `./ci/scripts/rust-lint.sh` passes, and `bazel build` of the replica,
the canister sandbox, `//rs/embedders:all`, the HTTPS-outcalls adapter,
ic-boundary, the orchestrator and the PocketIC server succeeds. The node
key and TLS certificate validation tests pass.
- `bazel build --config=fuzzing --build_tag_filters=libfuzzer //rs/...`,
which PR CI doesn't build for lock-only changes, succeeds.

This PR carries the `CI_ALL_BAZEL_TARGETS` label, so CI Main builds and
tests the same targets as on master, `long_test`s included.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants