Skip to content

Validation of exporting instance types with resources is not correct #1253

Open

Description

@alexcrichton

This component is currently rejected:

(component
  (type $t (instance
    (export $x1 "x1" (type (sub resource)))
    (export "f1" (func (result (own $x1))))
  ))

  (export "t" (type $t))
)
$ cargo run validate foo.wat --features component-model
    Finished dev [unoptimized + debuginfo] target(s) in 3.71s
     Running `target/debug/wasm-tools validate foo.wat --features component-model`
error: type not valid to be used as export (at offset 0x26)

but this component should be valid.

#1251 was a historical version of starting this, but required solving the problem of going from ResourceId to TypeId in a more robust way. That'd require some extra fields to be tracked in component instance types.

One reason we decided not to fix it at the time of that PR is that this starts opening some larger questions which we're not entirely sure the answer to about what possible ways to fix this are in scope and which modules are valid and not. To sidestep these questions we figured it'd be best to leave the current validation in place which effectively rejects any instance types with resources in them. This is not correct but hopefully won't cause any road bumps for anyone else down the line for awhile at least. The thinking is that when there's a more formal definition of the component model's validation rules we can rely on that for providing better answers of what's valid and what's not and better design a solution within those constraints.

Activity

  1. added
    component-model
    on Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component-model

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions