WebAssembly / WebAssembly/binaryen
Clean up FailToEvalExceptions and import stubbing in wasm-ctor.cpp
Open
@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,
getImportedTagthrows 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.