Skip to content

wasm-tools/wit-component tinygo wasip2 component mismatch  #4587

@elewis787

Description

@elewis787

@jeff1010322 and I recently ran into an issue with the version of wasm-tools causing the following error:

handler.wasmexport_Handle#wasmexport\nnote: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information",
    source: "unknown handle index 0",
}
error: hyper::Error(User(Service), guest never invoked `response-outparam::set` method: error while executing at wasm backtrace:
    0: 0x145611 - wit-component:shim!indirect-wasi:io/streams@0.2.0-[method]output-stream.blocking-write-and-flush
    1: 0xcbe5 - main!(internal/wasi/io/v0.2.0/streams.OutputStream).BlockingWriteAndFlush
    2: 0x1110c - main!runtime.putchar
    3: 0x11008 - main!runtime.printnl
    4: 0x10e93 - main!runtime.runtimePanicAt
    5: 0xc788 - main!runtime.runtimePanic
    6: 0xc93c - main!runtime.wasmExportCheckRun
    7: 0x417e6 - main!github.com/hayride-dev/bindings/go/wasihttp/gen/wasi/http/incoming-handler.wasmexport_Handle#wasmexport
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information

Caused by:
    unknown handle index 0)

This occurred when using tinygo v0.34 and wit-component 0.215 when targeting wasip2.

In order to get this to work, wit-component needed to be set to at least 0.218 and used to embed wasip2 components.
This was uncovered by inspecting the wat generated off a tinygo compiled wasm component

i.e

    (@producers
    (language "C99" "")
    (processed-by "TinyGo" "0.35.0-dev")
    (processed-by "wit-component" "0.218.0")

There are envs for WASMTOOLS that can be set https://github.com/tinygo-org/tinygo/blob/release/builder/build.go#L885.

However, there seems to still be a potential for a mismatch tinygo wasip2 support and wasm-tools version support.

Would it be acceptable to submodule wasm-tools and default to using the built binary from tinygo, and optionally fall back to the env that is set for wasmtools?

Alternatively, when embedding a wit package/world, could we require a wasm-tools version that is supported and error on mismatch, something similar to the go/llvm required version?

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasmWebAssembly

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions