vedantroy opened Issue #1547:
Thanks for opening a bug report! Please answer the questions below
if they're relevant and delete this text before submitting.Run the following file in wasmtime 0.15.0 and in whatever version of wasmer is installed with
curl https://get.wasmer.io -sSfL | sh
wasmer prints the expected output:
no foo. barwasmtime prints nothing
;; Taken from: https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-tutorial.md and modified (module (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32))) (memory 1) (data (i32.const 1024) "no foo.\nbar\n") (func $print_msg (param $array_ptr i32) (call $fd_write (i32.const 1) ;; file descriptor (local.get $array_ptr) ;; pointer to first iovec in array (i32.const 1) ;; len of array (i32.const 2048) ;; place to write number of bytes written ) drop ) (func $main (export "_start") ;; Creating a new io vector within linear memory (i32.store (i32.const 0) (i32.const 1024)) (i32.store (i32.const 4) (i32.const 8)) (i32.store (i32.const 8) (i32.const 1032)) (i32.store (i32.const 12) (i32.const 4)) (call $print_msg (i32.const 0)) (call $print_msg (i32.const 8)) ) )
vedantroy labeled Issue #1547:
Thanks for opening a bug report! Please answer the questions below
if they're relevant and delete this text before submitting.Run the following file in wasmtime 0.15.0 and in whatever version of wasmer is installed with
curl https://get.wasmer.io -sSfL | sh
wasmer prints the expected output:
no foo. barwasmtime prints nothing
;; Taken from: https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-tutorial.md and modified (module (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32))) (memory 1) (data (i32.const 1024) "no foo.\nbar\n") (func $print_msg (param $array_ptr i32) (call $fd_write (i32.const 1) ;; file descriptor (local.get $array_ptr) ;; pointer to first iovec in array (i32.const 1) ;; len of array (i32.const 2048) ;; place to write number of bytes written ) drop ) (func $main (export "_start") ;; Creating a new io vector within linear memory (i32.store (i32.const 0) (i32.const 1024)) (i32.store (i32.const 4) (i32.const 8)) (i32.store (i32.const 8) (i32.const 1032)) (i32.store (i32.const 12) (i32.const 4)) (call $print_msg (i32.const 0)) (call $print_msg (i32.const 8)) ) )
vedantroy edited Issue #1547:
Run the following file in wasmtime 0.15.0 and in whatever version of wasmer is installed with
curl https://get.wasmer.io -sSfL | sh
wasmer prints the expected output:
no foo. barwasmtime prints nothing
;; Taken from: https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-tutorial.md and modified (module (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32))) (memory 1) (data (i32.const 1024) "no foo.\nbar\n") (func $print_msg (param $array_ptr i32) (call $fd_write (i32.const 1) ;; file descriptor (local.get $array_ptr) ;; pointer to first iovec in array (i32.const 1) ;; len of array (i32.const 2048) ;; place to write number of bytes written ) drop ) (func $main (export "_start") ;; Creating a new io vector within linear memory (i32.store (i32.const 0) (i32.const 1024)) (i32.store (i32.const 4) (i32.const 8)) (i32.store (i32.const 8) (i32.const 1032)) (i32.store (i32.const 12) (i32.const 4)) (call $print_msg (i32.const 0)) (call $print_msg (i32.const 8)) ) )
vedantroy edited Issue #1547:
Run the following file in wasmtime 0.15.0 and in whatever version of wasmer is installed with
curl https://get.wasmer.io -sSfL | sh
wasmer prints the expected output:
no foo. barwasmtime prints nothing
;; Taken from: https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-tutorial.md and modified (module (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32))) (memory 1) (data (i32.const 1024) "no foo.\nbar\n") (func $print_msg (param $array_ptr i32) (call $fd_write (i32.const 1) ;; file descriptor (local.get $array_ptr) ;; pointer to first iovec in array (i32.const 1) ;; len of array (i32.const 2048) ;; place to write number of bytes written ) drop ) (func $main (export "_start") ;; Creating a new io vector within linear memory (i32.store (i32.const 0) (i32.const 1024)) (i32.store (i32.const 4) (i32.const 8)) (i32.store (i32.const 8) (i32.const 1032)) (i32.store (i32.const 12) (i32.const 4)) (call $print_msg (i32.const 0)) (call $print_msg (i32.const 8)) ) )I assume the issue is with wasmtime.
alexcrichton commented on Issue #1547:
Thanks for the report! The issue here is that the wasm linear memory isn't exported, but it's expected to be exported for wasi to work with it. You can fix this by replacing
(memory 1)
with(memory (export "memory") 1)
.The exact particulars here are a little up-in-the-air since historically wasi implementations would use a memory without requiring it be exported, but semantically that felt a little odd and we tweaked it to require an export. The
fd_write
call in the example you've written is returning an error becausememory
isn't exported, but the error is being ignored.
alexcrichton labeled Issue #1547:
Run the following file in wasmtime 0.15.0 and in whatever version of wasmer is installed with
curl https://get.wasmer.io -sSfL | sh
wasmer prints the expected output:
no foo. barwasmtime prints nothing
;; Taken from: https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-tutorial.md and modified (module (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32))) (memory 1) (data (i32.const 1024) "no foo.\nbar\n") (func $print_msg (param $array_ptr i32) (call $fd_write (i32.const 1) ;; file descriptor (local.get $array_ptr) ;; pointer to first iovec in array (i32.const 1) ;; len of array (i32.const 2048) ;; place to write number of bytes written ) drop ) (func $main (export "_start") ;; Creating a new io vector within linear memory (i32.store (i32.const 0) (i32.const 1024)) (i32.store (i32.const 4) (i32.const 8)) (i32.store (i32.const 8) (i32.const 1032)) (i32.store (i32.const 12) (i32.const 4)) (call $print_msg (i32.const 0)) (call $print_msg (i32.const 8)) ) )I assume the issue is with wasmtime.
Last updated: Dec 23 2024 at 13:07 UTC