Stream: git-wasmtime

Topic: wasmtime / issue #4985 Failed to run wasi module without ...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 07:14):

12101111 opened issue #4985:

Test Case

Compile this C code using wasi-sdk (wasi-libc is compiled with THREAD_MODEL=posix)

int main() {
  return 42;
}
> clang -pthread -Wl,--import-memory -Os hello.c -o test.wasm
> wasm-dis test.wasm
(module
 (type $i32_=>_none (func (param i32)))
 (type $none_=>_none (func))
 (import "wasi_snapshot_preview1" "proc_exit" (func $fimport$0 (param i32)))
 (export "_start" (func $0))
 (func $0
  (call $fimport$0
   (i32.const 42)
  )
  (unreachable)
 )
 ;; custom section "producers", size 108
 ;; features section: threads, mutable-globals, bulk-memory, sign-ext
)

Steps to Reproduce

> wasmtime test.wasm

Expected Results

Exit with code 42

Actual Results

Error: failed to run main module `test.wasm`

Caused by:
    0: failed to invoke command default
    1: missing required memory export
       wasm backtrace:
           0:   0x4f - <unknown>!<wasm function 1>

Versions and Environment

Wasmtime version or commit: wasmtime-cli 1.0.1

Operating system: macOS 12.6

Architecture: aarch64

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 07:14):

12101111 labeled issue #4985:

Test Case

Compile this C code using wasi-sdk (wasi-libc is compiled with THREAD_MODEL=posix)

int main() {
  return 42;
}
> clang -pthread -Wl,--import-memory -Os hello.c -o test.wasm
> wasm-dis test.wasm
(module
 (type $i32_=>_none (func (param i32)))
 (type $none_=>_none (func))
 (import "wasi_snapshot_preview1" "proc_exit" (func $fimport$0 (param i32)))
 (export "_start" (func $0))
 (func $0
  (call $fimport$0
   (i32.const 42)
  )
  (unreachable)
 )
 ;; custom section "producers", size 108
 ;; features section: threads, mutable-globals, bulk-memory, sign-ext
)

Steps to Reproduce

> wasmtime test.wasm

Expected Results

Exit with code 42

Actual Results

Error: failed to run main module `test.wasm`

Caused by:
    0: failed to invoke command default
    1: missing required memory export
       wasm backtrace:
           0:   0x4f - <unknown>!<wasm function 1>

Versions and Environment

Wasmtime version or commit: wasmtime-cli 1.0.1

Operating system: macOS 12.6

Architecture: aarch64

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 07:55):

bjorn3 commented on issue #4985:

Wasi requires the wasm module to export the linear memory, not import it.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 08:47):

12101111 commented on issue #4985:

When threads is enabled, the linear memory should import from host, otherwise there is no way to share single memory across threads.

And in this case, the linear memory is not used. It should be valid for wasi.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 10:01):

bjorn3 commented on issue #4985:

Wasi currently doesn't support threads.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 14:28):

alexcrichton closed issue #4985:

Test Case

Compile this C code using wasi-sdk (wasi-libc is compiled with THREAD_MODEL=posix)

int main() {
  return 42;
}
> clang -pthread -Wl,--import-memory -Os hello.c -o test.wasm
> wasm-dis test.wasm
(module
 (type $i32_=>_none (func (param i32)))
 (type $none_=>_none (func))
 (import "wasi_snapshot_preview1" "proc_exit" (func $fimport$0 (param i32)))
 (export "_start" (func $0))
 (func $0
  (call $fimport$0
   (i32.const 42)
  )
  (unreachable)
 )
 ;; custom section "producers", size 108
 ;; features section: threads, mutable-globals, bulk-memory, sign-ext
)

Steps to Reproduce

> wasmtime test.wasm

Expected Results

Exit with code 42

Actual Results

Error: failed to run main module `test.wasm`

Caused by:
    0: failed to invoke command default
    1: missing required memory export
       wasm backtrace:
           0:   0x4f - <unknown>!<wasm function 1>

Versions and Environment

Wasmtime version or commit: wasmtime-cli 1.0.1

Operating system: macOS 12.6

Architecture: aarch64

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 14:28):

alexcrichton commented on issue #4985:

This is an expected result of the WASI implementation today which is that despite some hostcalls not needing access to the wasm module's linear memory they all require access anyway. This ends up not being much of a problem in practice since modules which don't use a linear memory tend to not be too interesting. Solving this issue has been punted to the component model.

Otherwise as mentioned WASI doesn't support shared linear memory today with threads. Additionally Wasmtime does not have a complete implementation of the threads proposal.


Last updated: Nov 22 2024 at 17:03 UTC