Skip to content

interp: Handle ref.null exn - #2497

Merged
sbc100 merged 1 commit into
WebAssembly:mainfrom
SoniEx2:ehv4-defs
Oct 29, 2024
Merged

sbc100 merged 1 commit into
WebAssembly:mainfrom
SoniEx2:ehv4-defs

Conversation

@SoniEx2

@SoniEx2 SoniEx2 commented Oct 29, 2024

Copy link
Copy Markdown
Collaborator

No description provided.

@sbc100 sbc100 changed the title interp: handle ref.null exn interp: Handle ref.null exn Oct 29, 2024
@sbc100
sbc100 merged commit 6b3b81d into WebAssembly:main Oct 29, 2024
sbc100 pushed a commit that referenced this pull request Oct 28, 2026
PeekMatchRefType() admits `(ref ...)` when either function-references or
exceptions is enabled. Exceptions is on by default and
function-references is off, so with no flags the shorthand `(ref func)`,
the index form `(ref 0)` and the named form `(ref $t)` all reach the
typed reference parsing paths. The named form then trips
`assert(function_references_enabled())` in ParseValueTypeList and
ParseBoundValueTypeList, an abort in assert-enabled builds reachable
from untrusted .wat through wat2wasm and wast2json.

The exceptions condition came in with #2497, but nothing there needs it.
The exception-handling spec tests only use the `ref.null exn`
instruction, never a `(ref ...)` type. This gates PeekMatchRefType() on
function-references alone, so every `(ref ...)` form is rejected with
the parser's usual unexpected-token error when the feature is off, and
the two asserts hold again. `exnref` and `ref.null exn` still parse with
exceptions on, and `--enable-function-references` is unchanged.

Found by fuzzing the wat2wasm harness. Full run-tests.py suite and the
135 gtests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants