Skip to content

fd_write only prints first element of the iovec #629

@nomeata

Description

@nomeata

Consider this Wasm module:

(module
  (type (;0;) (func))
  (import "wasi_unstable" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32)))
  (memory (;0;) 2)
  (export "memory" (memory 0))
  (export "start" (func $start))
  (func $start (type 0)
    i32.const 1 ;; stdout
    i32.const 0 ;; iovec ptr
    i32.const 2 ;; entries
    i32.const 24 ;; out bytes
    call $fd_write
    drop
  )
  (data (i32.const 0) "\10\00\00\00\02\00\00\00\12\00\00\00\02\00\00\00ABCD")
)

if I run this as

wat2wasm fd_write_test.wat && wasmtime --disable-cache --invoke=start -d fd_write_test.wasm

I get

AB

not

ABCD

It seems thta fd_write only takes the first element of the iovec.

If I set the third argument to 0 it prints nothing (as it should).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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