Repository navigation
[FuzzExec] Give host imported functions exact types - #9314
Merged
Merged
Conversation
In WebAssembly with Custom Descriptors, an inexact function import has a static inexact type `(ref $t)` because at instantiation time an open type `$t` could be satisfied by a subtype. However, at runtime, every concrete function instance (including host functions) has an exact dynamic type, and when `$t` is a final type (`!isOpen()`), `GCTypeUtils::evaluateCastCheck` optimizes casts of `(ref $t)` to `(ref (exact $t))` to succeed. When `LoggingExternalInterface::getImportedFunction` was updated in #7993 to pass `import->type` instead of `import->type.getHeapType()`, host imported functions were given an inexact runtime `Literal` type, causing runtime casts of host imported functions to `(ref (exact $t))` to fail in `--fuzz-exec` after passes like `--remove-unused-brs` folded `br_on_cast` to `ref.cast`. Fix this by passing `import->type.with(Exact)` when constructing host function literals in `LoggingExternalInterface::getImportedFunction`.
tlively
requested review from
stevenfontanella
and removed request for
a team
October 27, 2026 04:13
There was a problem hiding this comment.
Code Review
This pull request updates the LoggingExternalInterface in src/tools/execution-results.h to ensure that host functions are returned with their exact import type by using import->type.with(Exact). It also adds corresponding test cases in imported-func.wast and imported-func.wast.second to verify the exact type casting behavior of host imports. There are no review comments, so I have no feedback to provide.
stevenfontanella
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In WebAssembly with Custom Descriptors, an inexact function import has a static inexact type
(ref $t)because at instantiation time an open type$tcould be satisfied by a subtype. However, at runtime, every concrete function instance (including host functions) has an exact dynamic type, and when$tis a final type (!isOpen()),GCTypeUtils::evaluateCastCheckoptimizes casts of(ref $t)to(ref (exact $t))to succeed.When
LoggingExternalInterface::getImportedFunctionwas updated in #7993 to passimport->typeinstead ofimport->type.getHeapType(), host imported functions were given an inexact runtimeLiteraltype, causing runtime casts of host imported functions to(ref (exact $t))to fail in--fuzz-execafter passes like--remove-unused-brsfoldedbr_on_casttoref.cast. Fix this by passingimport->type.with(Exact)when constructing host function literals inLoggingExternalInterface::getImportedFunction.