Stream: git-wasmtime

Topic: wasmtime / PR #12512 fix: make GLOBAL_CODE register/unreg...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 00:57):

zacharywhitley opened PR #12512 from tegmentum:fix/global-code-registry-idempotent to bytecodealliance:main:

Summary

This PR makes register_code and unregister_code operations idempotent to prevent SIGABRT crashes caused by virtual address reuse in long-running processes.

Fixes #12511

Problem

When creating and destroying many Engine and Module instances, the OS can reuse virtual addresses before all Arc<CodeMemory> references are fully released. This causes:

  1. Duplicate registration: New engine gets same address as old engine whose Arc hasn't been deallocated yet

    • assert!(prev.is_none()) fails → SIGABRT
  2. Double unregistration: Old Arc finally deallocates after new engine re-registered at same address

    • assert!(code.is_some()) fails → SIGABRT

This consistently crashes after ~350-400 engine/module creations in a single process.

Solution

Add a BTreeSet to track registered addresses and check before performing operations:

This makes both operations safe to call multiple times with the same address.

Changes

Testing

Impact

This fix enables:

Backward Compatibility

view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 00:57):

zacharywhitley requested wasmtime-compiler-reviewers for a review on PR #12512.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 00:57):

zacharywhitley requested fitzgen for a review on PR #12512.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 00:57):

zacharywhitley requested wasmtime-wasi-reviewers for a review on PR #12512.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 00:57):

zacharywhitley requested wasmtime-core-reviewers for a review on PR #12512.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 00:57):

zacharywhitley requested wasmtime-default-reviewers for a review on PR #12512.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 01:07):

zacharywhitley updated PR #12512.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 01:39):

alexcrichton closed without merge PR #12512.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2026 at 01:39):

alexcrichton commented on PR #12512:

I don't believe that this fix is correct, so I'm going to close this in favor of continuing discussion on https://github.com/bytecodealliance/wasmtime/issues/12511.


Last updated: Feb 24 2026 at 04:36 UTC