WebAssembly / WebAssembly/binaryen

Clean up FailToEvalExceptions and import stubbing in wasm-ctor.cpp

Open
#8,117 0 comments 0 reactions 1 assignee View on GitHub

@stevenfontanella is already working on this.

Since Dec 12, 2025.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

The way that imports are handled in wasm-ctor.cpp is pretty unclear today. All imports must be present, but typically we raise FailToEvalException when trying to read/write them since we don't know what the import contains at the time that wasm-ctor runs. That much is fine, but the code is inconsistent in how it does this.

  • For tags, getImportedTag throws an unreachable exception.
  • For memories, the tracking table isn't populated during init, so reads and writes to memories will fail saying that the imported memory doesn't exist: link.
  • Functions are stubbed with unreachable (for the 'env' module, and for all modules after #8115).
  • And tables and globals will throw FailToEvalException link.

These all correctly stop evaluation when trying to observe or write to an import, but they all do it in different ways which is confusing. We should clean up the logic here.

Contributor guide

Open the contributing guide

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.