Skip to content

Conversation

@zacharywhitley
Copy link

Summary

When the component-model-async feature is compiled in but the store was created without concurrency support, concurrent_state is None. During Store::drop, drop_fibers_and_futures is called which then calls concurrent_state_mut(). This panics because concurrent_state_mut() unwraps the None value.

This fix adds a runtime check to early-return when concurrency_support() returns false, preventing the panic during Store drop.

Problem

In crates/wasmtime/src/runtime/store.rs:

pub(crate) fn concurrent_state_mut(&mut self) -> &mut concurrent::ConcurrentState {
    debug_assert!(self.concurrency_support());
    self.concurrent_state.as_mut().unwrap()  // Panics if concurrent_state is None
}

The debug_assert! only catches this in debug builds, but in release builds the unwrap() will panic.

Fix

Add a guard in drop_fibers_and_futures:

pub(crate) fn drop_fibers_and_futures(store: &mut dyn VMStore) {
    if !store.concurrency_support() {
        return;
    }
    // ... rest of cleanup
}

Test Plan

  • Builds successfully with cargo check -p wasmtime --features component-model,component-model-async,async
  • Confirmed fix prevents panic when dropping stores created without concurrency support

When the component-model-async feature is compiled in but the store
was created without concurrency support (e.g., via Config tuning),
concurrent_state is None. Calling concurrent_state_mut() in this case
would panic due to the unwrap() on None.

This fix adds a runtime check to early-return when concurrency_support
is false, preventing the panic during Store drop.
@zacharywhitley zacharywhitley requested a review from a team as a code owner February 4, 2026 12:51
@zacharywhitley zacharywhitley requested review from fitzgen and removed request for a team February 4, 2026 12:51
@github-actions github-actions bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Feb 4, 2026
@alexcrichton
Copy link
Member

Can you add a test for this as well? Somewhere in tests/all/*.rs for example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants