Stream: git-wasmtime

Topic: wasmtime / issue #9848 Error linking to function that tak...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 01:08):

viridia added the bug label to Issue #9848.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 01:08):

viridia opened issue #9848:

I'm getting this error:

types incompatible: expected type `(func (param (ref array (engine 5))))`, found type `(func (param (ref array)))`

The wasm looks like this:

(type $String (;3;) (array i8))
(type $debug.type (;4;) (func (param (ref $String))))
(import "host" "debug" (func $debug (;0;) (type $debug.type)))

And I'm registering the function like this:

let engine = wasmtime::Engine::new(&config).unwrap();
let store = wasmtime::Store::<StoreData>::new(&engine, ());
let mut linker = wasmtime::Linker::new(&engine);
linker
    .func_wrap(
        "host",
        "debug",
        |caller: Caller<'_, StoreData>, param: Rooted<ArrayRef>| {
            // ...
        },
    )
    .unwrap();

Test Case

(module $hello.saga
  (type $hello.type (;0;) (func (result i32)))
  (type $add.type (;1;) (func (param i32) (result i32)))
  (type $name.type (;2;) (func))
  (type $String (;3;) (array (mut i8)))
  (type $debug.type (;4;) (func (param (ref $String))))
  (import "host" "debug" (func $debug (;0;) (type $debug.type)))
  (export "hello" (func $hello))
  (func $hello (;1;) (type $hello.type) (result i32)
    i32.const 1
    call $add
    i32.const 2
    i32.add
    f32.const 0x1.8p+1 (;=3;)
    i32.trunc_f32_s
    i32.add
    return
  )
  (func $add (;2;) (type $add.type) (param i32) (result i32)
    (local i32)
    i32.const 1
    local.set 1
    local.get 0
    local.get 1
    i32.add
    return
  )
  (func $name (;3;) (type $name.type)
    i32.const 0
    i32.const 15
    array.new_data $String 0
    call $debug
  )
  (data (;0;) "Hello from SAGA")
)

Steps to Reproduce

Create an Engine and Linker.
Bind a function which accepts an ArrayRef as a parameter.
Attempt to load the script.

Expected Results

Script should load without error (it loads if I delete the code that calls the host func).

Actual Results

Error when I attempt to instantiate the script.

Versions and Environment

Wasmtime version or commit: { version = "27.0.0", features = ["gc", "gc-drc"] }

Operating system: OS X

Architecture: M2

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 15:54):

alexcrichton assigned fitzgen to issue #9848.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 17:16):

fitzgen commented on issue #9848:

Thanks for filing an issue. I won't have time to look into this for a while, unfortunately, but I appreciate getting it on the record for posterity.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2024 at 17:51):

fitzgen added the wasmtime:ref-types label to Issue #9848.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2024 at 17:51):

fitzgen added the wasm-proposal:gc label to Issue #9848.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2024 at 17:52):

github-actions[bot] commented on issue #9848:

Subscribe to Label Action

cc @fitzgen

<details>
This issue or pull request has been labeled: "wasmtime:ref-types"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2024 at 17:53):

fitzgen commented on issue #9848:

FWIW, this is probably related to the WasmTy implementation for ArrayRef


Last updated: Dec 23 2024 at 13:07 UTC