Skip to content

wasmparser: Valid Wasm is not accepted if bulk-memory is enabled and reference-types is disabled #889

Open
@Robbepop

Description

@Robbepop

I stumbled upon this when implementing bulk-memory Wasm proposal support in wasmi when integrating the new Wasm spec testsuite test cases for the bulk-memory Wasm proposal. Note: wasmi does not yet have support for the reference-types Wasm proposal and I guess this is important for this issue.

Namely, when parsing and validating the test cases via wasmparser (as always) it errors out with this message among others:

---- spec::bulk_memory::wasm_table_copy stdout ----
thread 'spec::bulk_memory::wasm_table_copy' panicked at 'tests/spec/testsuite/proposals/bulk-memory-operations/table_copy.wast: failed to execute `.wast` directive: reference types support is not enabled (at offset 0x74)', crates\wasmi\tests\spec\run.rs:44:9

---- spec::bulk_memory::wasm_table_init stdout ----
thread 'spec::bulk_memory::wasm_table_init' panicked at 'tests/spec/testsuite/proposals/bulk-memory-operations/table_init.wast: failed to execute `.wast` directive: reference types support is not enabled (at offset 0x74)', crates\wasmi\tests\spec\run.rs:44:9

The wasmparser error message is: reference types support is not enabled (at offset 0x74)
Querying the wasmparser codebase got me the following code segments:


Err("reference types support is not enabled")

Which filters out ValType::FuncRef | ValType::ExternRef types, however, the bulk-memory Wasm proposal explicitly allows ValType::FuncRef in so-called elemexpr which can only occur in Wasm element const experessions. I think this is the problematic code. (Not tested though.)

elemexpr = refnull | funcref <func_idx>

Source: bulk-memory Wasm Proposal Overview
elemexpr


(desc reference_types) => ("reference types");

Unfortunately I am on wasmparser 0.91 so this issue might have already been resolved in a newer version.
Here is a link to the WIP wasmi PR in case this helps. (It is very WIP ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions