Skip to content

Fix current instance count on failure during component instantiation#13048

Open
alexcrichton wants to merge 1 commit intobytecodealliance:mainfrom
alexcrichton:fix-decrement
Open

Fix current instance count on failure during component instantiation#13048
alexcrichton wants to merge 1 commit intobytecodealliance:mainfrom
alexcrichton:fix-decrement

Conversation

@alexcrichton
Copy link
Copy Markdown
Member

This commit fixes an issue during component instantiation where if instantiation failed during creation of the Instantiator due to OOM or if the async future was dropped the concurrent instance count in the pooling allocator would get corrupted (off-by-one). The fix here is to switch a map_err with a manual decrement to using a value that has a
destructor to ensure that it handles both of these cases.

This commit fixes an issue during component instantiation where if
instantiation failed during creation of the `Instantiator` due to OOM or
if the `async` future was dropped the concurrent instance count in the
pooling allocator would get corrupted (off-by-one). The fix here is to
switch a `map_err` with a manual decrement to using a value that has a
  destructor to ensure that it handles both of these cases.
@alexcrichton alexcrichton requested review from a team as code owners April 10, 2026 21:27
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team April 10, 2026 21:27
Comment on lines +1210 to +1212
// Everything has passed, don't decrement the instance count and let the
// destructor for the `Store` handle that at this point.
decrement.enabled = false;
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.

Instead of an enabled flag, maybe mem::forget(decrement) here? LLVM can probably keep enabled from being materialized at runtime, but the forget pattern seems no worse for ergonomics and guarantees that we won't need a bool flag at runtime.

@github-actions github-actions bot added fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown

Subscribe to Label Action

cc @fitzgen

Details This issue or pull request has been labeled: "fuzzing", "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

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

Labels

fuzzing Issues related to our fuzzing infrastructure 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