`Func::call` aborts on OOM when Wasm traps (with name section) or throws

Open
#15,529 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@cfallin is already working on this.

Since Dec 2, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust, wasm
Domain
backend

Research direction

Start with the OOM fuzz target at fuzz/fuzz_targets/oom.rs and the Func::call exception and trap paths described in the issue. Check the linked pull request #15530 for work already underway, then review how exception rooting creates DebugEvents and how wasm_backtrace(true) handles traps. Done means the unnecessary allocation is avoided when no debug handler is registered and the backtrace OOM limitation is documented.

Written by the indexing model from the issue text.

Description

It turns out that Func::call is not quite fully OOM-safe, despite our documentation that says it should be.

There are two ways in which we can still get an OOM:

  • Exception propagation from guest to host, which always does an infallible allocation due to the rooting of the thrown exception.

    • The rooting is done in order to create a DebugEvent, but this is actually unnecessary whenever a debug handler is not registered (i.e., most of the time)!
  • A trap, when backtraces are enabled (default) and the module has a name section. Maybe this is just a documentation imprecision: we could/should document that Wasm backtrace production is not yet OOM-safe?

This was missed by our OOM-fuzzing because the OOM-fuzzer disables exceptions and does not include a name section in its generated modules.

I believe there are easy fixes for both: (i) conditionally create the DebugEvent for an exception only when a handler is registered (d'oh!), and document that with wasm_backtrace(true), we are not yet OOM-safe.

I'm not sure about the reasoning for disabling exceptions in the fuzzer (here) -- cc @fitzgen on that one?

Dominant language
Rust
Stars
18.9k
Forks
2k
Avg merge
1d 6h
Merged PRs (30d)
238

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bytecodealliance/wasmtime

All issues in bytecodealliance/wasmtime

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.