Skip to content

[FuzzExec] Give host imported functions exact types - #9314

Merged
tlively merged 1 commit into
mainfrom
fuzz-exec-exact-imported-func
Oct 27, 2026
Merged

tlively merged 1 commit into
mainfrom
fuzz-exec-exact-imported-func

Conversation

@tlively

@tlively tlively commented Oct 27, 2026

Copy link
Copy Markdown
Member

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.

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
tlively requested a review from a team as a code owner October 27, 2026 04:13
@tlively
tlively requested review from stevenfontanella and removed request for a team October 27, 2026 04:13

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tlively
tlively merged commit 6a56e6c into main Oct 27, 2026
17 checks passed
@tlively
tlively deleted the fuzz-exec-exact-imported-func branch October 27, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants