Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to run file with imports from both "wasi_unstable" and "wasi_snapshot_preview1" #2226

Closed
jsimnz opened this issue Apr 2, 2021 · 0 comments · Fixed by #2251
Closed
Assignees
Labels
bug Something isn't working

Comments

@jsimnz
Copy link

jsimnz commented Apr 2, 2021

Describe the bug

Wasmer failing to run a wasm file with mixed WASI imports.

I have a compiled file with the following imports:

(import "wasi_unstable" "fd_write" (func $runtime.fd_write (type 1)))
(import "wasi_unstable" "clock_time_get" (func $runtime.clock_time_get (type 2)))
(import "wasi_snapshot_preview1" "environ_sizes_get" (func $__wasi_environ_sizes_get (type 3)))
(import "wasi_snapshot_preview1" "proc_exit" (func $__wasi_proc_exit (type 0)))
(import "wasi_snapshot_preview1" "environ_get" (func $__wasi_environ_get (type 3)))

I'm not sure why my specific compiler (tinygo) produces mixed output, but I believe it should work regardless.

When trying to run the following command

wasmer run main.wat

It returns the following error:

error: failed to run `main.wat`
╰─> 1: Error while importing "wasi_unstable"."fd_write": unknown import. Expected Function(FunctionType { params: [I32, I32, I32, I32], results: [I32] })

However, If I manually edit the .wat file, and change the imports to all use either "wasi_unstable" or "wasi_snapshot_preview1", it works without issue, only with mixed versions does it produce the error.

I am using the following version

echo "`wasmer -V`" : wasmer 1.0.2

Steps to reproduce

Run a wasm file with mixed WASI version imports.

Expected behavior

Run the file and produce the correct program output without issue

Actual behavior

Returns the following error:

error: failed to run `main.wat`
╰─> 1: Error while importing "wasi_unstable"."fd_write": unknown import. Expected Function(FunctionType { params: [I32, I32, I32, I32], results: [I32] })

Additional Context

I have verified that the original wasm file, with the mixed WASI import versions runs succesfully using the wasmtime runtime.

@jsimnz jsimnz added the bug Something isn't working label Apr 2, 2021
bors bot added a commit that referenced this issue Apr 28, 2021
2251: Allow CLI to exec WASI w/ multiple namespaces r=MarkMcCaskey a=MarkMcCaskey

resolves #2226 

Added a warning when it's done and a flag to opt out of the warning: `--allow-multiple-wasi-versions`

Wasm module to test with: [mixed-wasi.wasm.tar.gz](https://github.com/wasmerio/wasmer/files/6360575/mixed-wasi.wasm.tar.gz)

# Review

- [x] Add a short description of the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants